|  | 
	                
  
    | 
	 
        สอบถามเรื่องการเรียงลำดับผลลัพธ์ในการค้นหาหน่อยครับ     |  
    |  |  
 
              
  
    | 
 
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลบแถวที่ไม่ต้องการครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-08 15:14:19 | By :
                            apisitp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | คำถามสุดท้ายครับพี่ๆ ส่วนอื่นๆ ผมได้หมดเเล้วครับ ต้องขอบคุณพี่ๆมากเลยครับ สุดท้าย คือผมอยากให้เวลาค้นหาคำว่า "Core Switch" แล้วข้อมูลในแถวที่มีคำว่า "Core Switch" ไม่ต้องแสดง ให้แสดงข้อมูลที่ไม่มี "Core Switch" แทนหน่ะครับ เช้น ค้นหา A ไม่ให้ A แสดง แสดงแต่ B หรือถ้าค้นหา B ไม่ให้ B แสดง แสดงแต่ A 
 ขอบพระคุณมากๆครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-08 17:55:00 | By :
                            lekjaengs |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | NOT LIKE 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-08 18:53:02 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ค้น a เอาอันที่ไม่ไช่ a หรือ เอาอันที่ไม่มีส่วนประกอบของa ครับ 
 ถ้าใช้ not like  คือไม่เอาอันที่มีส่วนประกอบของคำนี้ >>>> filde not like %text%
 ถ้าใช้ <> (อ่านว่าไม่เท่ากับ ) คือไม่เอาอันที่เป็นคำนี้(แบบfulltext) >>>>> filde <> text
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-08 20:57:35 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | นั้นเหละครับ ถามต่อว่า  ค้น A ไม่เอา A นี่หมายความว่าไม่เอาทั้งหมดหรือไม่เอาคำที่มีส่วนประกอบ เช่น 
 นายสม และ นายสมชาย ถูกเก็บอยู่ใน DB
 1คำค้น "นายสม"  นายสม และ นายสมชาย ไม่ต้องออกมา <<< ยังนี้ใช้ not like
 2 คำค้น "นายสม" นายสมไม่ต้องออกมา แต่นายสมชายออกมา <<< ยังงี้ใช้ไม่เท่ากับ <>
 
 |  
              | 
 ประวัติการแก้ไข
 2013-11-08 21:26:45
 2013-11-08 21:27:30
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-08 21:24:31 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | DB_A  , DB_B  คงจะหมายถึง ฟิลล์A  , ฟิลล์ B ไช่ไหมครับ *--* คงไม่คิวรี่ข้าม DB นะไม่งั้นเรื่องใหญ่ 5 5  5 
 ใช้ NOT LIKE แต่!!! จะเชื่อด้วยโอปอเรเตอร์ OR ไม่ได้ครับ .. .  เพราะว่ามันเป็นทิศทางตรงข้ามกันกับ LIKE
 
 นิยามมั่วๆ. . . .
 ตามหลักคณิตศาสตร์แล้ว ให้ LIKE เท่ากับ "N"    มี NOT LIKE เป็นทิศทา่งตรงข้าม  LIKE ดังนั้นมันคือ ~N
 เมื่อปกติ  N OR N   แต่เมื่อ ~N  ต้องเชื่อมใหม่เป็ฯ  ~N AND ~N
 
 
 สรุปว่าใส่ . . . NOT LIKE แบบข้างบนถูกแล้วครับ แต่ต้องเชื่อมด้วยโอปอเรเตอร์  "AND" ลองดูครับ
 
 |  
              | 
 ประวัติการแก้ไข
 2013-11-08 22:57:57
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-08 22:27:06 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | พื้นฐานคิวรี่ หาอ่านเพิ่มเติมนะ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-09 07:27:53 | By :
                            telesyn |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | select * from table where (B1  LIKE %$text_search%) or (B2 NOT LIKE %$text_search%) or (B3 NOT LIKE %$text_search%) or (B4 NOT LIKE %$text_search%) order by ASC
 ในเมื่อจะหาใน A แล้วไม่สน A ก็ลองหาจาก B ไปตรง ๆ ได้เปล่า??
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-09 13:31:01 | By :
                            apisitp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | เหอะ ๆ มีแต่เรื่องยาก ๆ เน๊อะ... แล้วไม ไม่แยกเก็บไปเลยล่ะ
 ถ้ายังไม่ได้ใช้ระบบจริง
 น่าจะแยกทันอยู่ ฮิ้วววววววววววววววววว
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-09 14:12:31 | By :
                            apisitp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | รู้สึกจะออกแบบฐานข้อมูลแปลกๆนะครับ  ลองเอา DB มากางให้เพื่อนๆสมาชิกช่วยกันคิด น่าจะได้ครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-09 14:13:37 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              |  
 ฐานข้อมูล ผมทำออกมาเป็นก้อนเดียว เเต่ยาวๆหน่ะครับ มันได้ไหม๊ครับ ครั้งนี้จะเป็นครั้งสุดท้ายที่ออกเเบบฐานข้อมูลได้เกรียนเเบบนี้หน่ะครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-09 14:32:31 | By :
                            lekjaengs |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ผมลองอัพฐานข้อมูลแล้วครับ ค้นข้อมูลไม่ว่าจะอยู่ตรงไหน ให้เเสดงข้อมูลที่ตรงกันข้าม มันทำอย่างไงหรอครับ สมมุติ ค้นเจอคำว่า Firewall ไปอยู่ _b ให้ข้อมูลที่เป็น _a แสดง งงจุงๆ ช่วยทีครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-09 22:58:14 | By :
                            lekjaengs |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ถามชัดๆเลยว่า ..  . . 1.  _a และ _b อยู่ ในตารางเดียวกัน หรือ คนละตารางแต่ DB เดียวกัน   หรือ อยู่คนละ DBกันเลย
 
 |  
              | 
 ประวัติการแก้ไข
 2013-11-09 23:22:59
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-09 23:19:45 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
 
 
 
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ติดตามเหมือนกัน : กว่าจะจบ...555+  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-10 08:24:58 | By :
                            apisitp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | อาจมีเทคนิค SQL ที่ดีกว่านี้ครับ อาจจะมีศัพทืแปลกๆที่เอาไว้ใช้งานประเภทนี้ ที่เราไม่ค่อยเห็นมากนักในชีวิตประจำวัน.. .....รอท่านอื่นๆครับ ผมนึกวิธีไม่ออกจริงๆนอกจากวิธีนี้ 555 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-10 11:33:21 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | อาจจะต้องถามลูกพี่ผม คุณ 9713 เค้าอาจจะมีวิธีเทพๆกว่านี้ครับ  รายนั้นไม่ธรรมดา แต่ต้องถามในจังหวะเวลาที่เป็นฤกงามยามดีนะ ไม่เช่นนั้นจะได้ปริศนาธรรมมาแทน
 ซึ่งมันจะเป็นอะไรที่ลึกซึ้งกว่าโค้ดหลายเท่าตัวนัก
  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-10 16:20:38 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ผมคิดออกละครับ  ขอ Full code โพสส์มาอีกทีใช้ได้แน่ๆ มีแนวคิดมาดังนี้ 
 เดิม
 
  
 ใหม่
 
  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-10 17:03:34 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ลองใหม่ดูอาจจะเออเร่อนะ 
 
 <html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
<script type="text/javascript" src="jquery-latest.js"></script> 
<script type="text/javascript" src="jquery.tablesorter.js"></script> 
<link href="themes/blue/style.css" rel="stylesheet" type="text/css">
</head>
<script type="text/javascript">
	$(document).ready(function() { 
		$("#myTable").tablesorter(); 
	}); 
</script>
<body>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
  <table width="599" id="large" class="tablesorter" border="1">
    <tr>
      <th>Keyword
      <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>">
      <input type="submit" value="Search"></th>
    </tr>
  </table>
</form>
<?
if($_GET["txtKeyword"] != "")
	{
	$objConnect = mysql_connect("localhost","root","11223344") or die("Error Connect to Database");
	$objDB = mysql_select_db("destination");
	
	$strSQL_x = "SELECT * FROM sourcedestination" ORDER BY id ASC;  //ปรับเรียงมากไปน้อยน้อยไปมากที่นี้
	$objQuery_x = mysql_query($strSQL_x) or die ("Error Query [".$strSQL_x."]");
	while($objResult_x = mysql_fetch_array($objQuery_x))
	{
	$id_check=$objResult_x["id"];
	
	// Search By Name or Email
	$strSQL1 = "SELECT * FROM sourcedestination WHERE(
	room_a LIKE '%".$_GET["txtKeyword"]."%' 
	or row_a LIKE '%".$_GET["txtKeyword"]."%' 
	or rack_a LIKE '%".$_GET["txtKeyword"]."%' 
	or brand_a LIKE '%".$_GET["txtKeyword"]."%' 
	or brands_a LIKE '%".$_GET["txtKeyword"]."%' 
	or storage_a LIKE '%".$_GET["txtKeyword"]."%' 
	or port_a LIKE '%".$_GET["txtKeyword"]."%' 
	or ports_a LIKE '%".$_GET["txtKeyword"]."%' 
	or sourcelocation_a LIKE '%".$_GET["txtKeyword"]."%' 
	or sourceport_a LIKE '%".$_GET["txtKeyword"]."%' 
	or interface_a LIKE '%".$_GET["txtKeyword"]."%'
	or protocol_a LIKE '%".$_GET["txtKeyword"]."%'
	or product_a LIKE '%".$_GET["txtKeyword"]."%'
	or devicename_a LIKE '%".$_GET["txtKeyword"]."%'
	or ipaddress_a LIKE '%".$_GET["txtKeyword"]."%'
	or destinationport_a LIKE '%".$_GET["txtKeyword"]."%'
	or destinationlocation_a LIKE '%".$_GET["txtKeyword"]."%'
	or remark_a LIKE '%".$_GET["txtKeyword"]."%') AND id = '$id_check' ";
	$objQuery1 = mysql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
	
	$strSQL2 = "SELECT * FROM sourcedestination WHERE (
	room_b LIKE '%".$_GET["txtKeyword"]."%'
	or row_b LIKE '%".$_GET["txtKeyword"]."%'
	or rack_b LIKE '%".$_GET["txtKeyword"]."%'
	or brand_b LIKE '%".$_GET["txtKeyword"]."%'
	or brands_b LIKE '%".$_GET["txtKeyword"]."%'
	or storage_b LIKE '%".$_GET["txtKeyword"]."%'
	or ports_b LIKE '%".$_GET["txtKeyword"]."%'
	or sourcelocation_b LIKE '%".$_GET["txtKeyword"]."%'
	or sourceport_b LIKE '%".$_GET["txtKeyword"]."%'
	or interface_b LIKE '%".$_GET["txtKeyword"]."%'
	or protocol_b LIKE '%".$_GET["txtKeyword"]."%'
	or product_b LIKE '%".$_GET["txtKeyword"]."%'
	or devicename_b LIKE '%".$_GET["txtKeyword"]."%'
	or ipaddress_b LIKE '%".$_GET["txtKeyword"]."%'
	or destinationport_b LIKE '%".$_GET["txtKeyword"]."%'
	or destinationlocation_b LIKE '%".$_GET["txtKeyword"]."%'
	or remark_b LIKE '%".$_GET["txtKeyword"]."%') AND id = '$id_check' ";
	$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL2."]");
	
	?>
    
    
<table id="myTable" class="tablesorter"> 
<thead> 
     
      <tr>
		<th width="58" align="center" valign="middle" bgcolor="#999999" ><strong>Edit|Del</strong></td>
            <th  width="164" height="26" align="center" valign="middle" bgcolor="#999999"><strong>Source Location</strong></td>
            <th width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source Port</strong></td>
            <th width="64" align="center" valign="middle" bgcolor="#999999"><strong>Interface</strong></td>
            <th width="57" align="center" valign="middle" bgcolor="#999999"><strong>Protocol</strong></td>
            <th bgcolor="#FF0000"></td><th width="161" align="center" valign="middle" bgcolor="#999999" ><strong> Product</strong></td>
            <th width="132" align="center" valign="middle" bgcolor="#999999" ><strong>Device Name</strong></td>
            <th width="95" align="center" valign="middle" bgcolor="#999999" ><strong>IP Address</strong></td>
            <th width="127" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Port</strong></td>
            <th width="165" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Location</strong></td>
            <th width="76" align="center" valign="middle" bgcolor="#999999" ><strong>Remark</strong></td>
	  </tr>
      </thead> 
<tbody> 
	<?
// ****************************  อันนี้ mysql_fetch_array  ----> LIKE _a  แต่โชว์ข้อมูล _b *********************
	if($objResult1 = mysql_fetch_array($objQuery1))
	{
	?>
	  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult1["id"];?>"><img src="image/1378293707_cog_edit.png" width="20" height="20"></a><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='phpMySQLDeleteRecord.php?id=<?=$objResult1["id"];?>';}"><img src="image/1378571326_button_cancel.png" width="20" height="20"></a></td>
    <td height="20" align="center"><?=$objResult1["sourcelocation_b"];?></td>
    <td height="20" align="center"><?=$objResult1["sourceport_b"];?></td>
    <td height="20" align="center"><?=$objResult1["interface_b"];?></td>
    <td height="20" align="center"><?=$objResult1["protocol_b"];?></td><td bgcolor="#FF0000">
    <td height="20" align="center"><?=$objResult1["product_b"];?></td>
    <td height="20" align="center"><?=$objResult1["devicename_b"];?></td>
    <td height="20" align="center"><?=$objResult1["ipaddress_b"];?></td>
    <td height="20" align="center"><?=$objResult1["destinationport_b"];?></td>
    <td height="20" align="center"><?=$objResult1["destinationlocation_b"];?></td>
    <td height="20" align="center"><?=$objResult1["remark_b"];?></td>
  </tr>
	<?
	} //****************************ปิด LOOP LIKE A SHOW B
// ****************************  อันนี้ mysql_fetch_array  ----> LIKE _a  แต่โชว์ข้อมูล _b *********************
	if($objResult2 = mysql_fetch_array($objQuery2))
	{
	?>
	  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult2["id"];?>"><img src="image/1378293707_cog_edit.png" width="20" height="20"></a><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='phpMySQLDeleteRecord.php?id=<?=$objResult2["id"];?>';}"><img src="image/1378571326_button_cancel.png" width="20" height="20"></a></td>
    <td height="20" align="center"><?=$objResult2["sourcelocation_a"];?></td>
    <td height="20" align="center"><?=$objResult2["sourceport_a"];?></td>
    <td height="20" align="center"><?=$objResult2["interface_a"];?></td>
    <td height="20" align="center"><?=$objResult2["protocol_a"];?></td><td bgcolor="#FF0000">
    <td height="20" align="center"><?=$objResult2["product_a"];?></td>
    <td height="20" align="center"><?=$objResult2["devicename_a"];?></td>
    <td height="20" align="center"><?=$objResult2["ipaddress_a"];?></td>
    <td height="20" align="center"><?=$objResult2["destinationport_a"];?></td>
    <td height="20" align="center"><?=$objResult2["destinationlocation_a"];?></td>
    <td height="20" align="center"><?=$objResult2["remark_a"];?></td>
  </tr>
  </tbody> 
	<?
	} //****************************ปิด LOOP LIKE B SHOW A
	} //ปิด Loop _x
	?>
    </table>
	<?
	mysql_close($objConnect);
}
?>
</body>
</html>
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-10 17:28:34 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | อ่อลืมเอาหัวข้อออกไปนอก Loop ครับ 
 ยกบรรทัดที่ 82 -  99  ไปไว้บรรทัดที่ 23 ครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-10 17:40:58 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | มาปรึกษาพี่ๆอีกเเล้วครับ ตอนเเรก ได้หมดเเล้วครับ เพียงแต่ว่า จะทำอย่างไรถ้าข้อมูลเยอะๆเเล้วมันไม่เรียงให้หน่ะครับ ถ้าข้อมูลน้อยๆมันจะเรียงครับ ตามที่ผม ไฮไลค์ไว้ ผมต้องเพิ่มคำสั่งอย่างไรให้ตอนค้นหาทั้งหมดเรียกมาโชว์เเล้วค่อยจัดเรียงหรอครับ 
 
  
 Code (PHP)
 
 <html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
<script type="text/javascript" src="jquery-latest.js"></script> 
<script type="text/javascript" src="jquery.tablesorter.js"></script> 
<link href="themes/blue/style.css" rel="stylesheet" type="text/css">
</head>
<script type="text/javascript">
	$(document).ready(function() { 
		$("#myTable").tablesorter(); 
	}); 
</script>
<body>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
  <table width="599" id="large" class="tablesorter" border="1">
    <tr>
      <th>Keyword
      <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>">
      <input type="submit" value="Search"></th>
    </tr>
  </table>
</form>
<table id="myTable" class="tablesorter"> 
<thead> 
     
      <tr>
		<th width="58" align="center" valign="middle" bgcolor="#999999" ><strong>Edit|Del</strong></td>
            <th  width="164" height="26" align="center" valign="middle" bgcolor="#999999"><strong>Source Location</strong></td>
            <th width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source Port</strong></td>            
            <th width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source Product</strong></td>
            <th width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source Device Name</strong></td>
            <th width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source IP Address</strong></td>    
            <th width="64" align="center" valign="middle" bgcolor="#999999"><strong>Interface</strong></td>
            <th width="57" align="center" valign="middle" bgcolor="#999999"><strong>Protocol</strong></td>
            <th bgcolor="#FF0000"></td><th width="161" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Product</strong></td>
            <th width="132" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Device Name</strong></td>
            <th width="95" align="center" valign="middle" bgcolor="#999999" ><strong>Destination IP Address</strong></td>
            <th width="127" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Port</strong></td>
            <th width="165" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Location</strong></td>
            <th width="76" align="center" valign="middle" bgcolor="#999999" ><strong>Remark</strong></td>
	  </tr>
      </thead> 
<tbody> 
<?
if($_GET["txtKeyword"] != "")
	{
	$objConnect = mysql_connect("localhost","root","11223344") or die("Error Connect to Database");
	$objDB = mysql_select_db("destination");
	
	
	$strSQL_x = "SELECT * FROM sourcedestination ORDER BY sourceport_a  ASC ";  //ปรับเรียงมากไปน้อยน้อยไปมากที่นี้
	$objQuery_x = mysql_query($strSQL_x) or die ("Error Query [".$strSQL_x."]");
	
	while($objResult_x = mysql_fetch_array($objQuery_x))
	{
	$id_check=$objResult_x["id"];
	
	// Search By Name or Email
	$strSQL1 = "SELECT * FROM sourcedestination WHERE(
	room_a LIKE '%".$_GET["txtKeyword"]."%' 
	or row_a LIKE '%".$_GET["txtKeyword"]."%' 
	or rack_a LIKE '%".$_GET["txtKeyword"]."%' 
	or brand_a LIKE '%".$_GET["txtKeyword"]."%' 
	or brands_a LIKE '%".$_GET["txtKeyword"]."%' 
	or storage_a LIKE '%".$_GET["txtKeyword"]."%' 
	or port_a LIKE '%".$_GET["txtKeyword"]."%' 
	or ports_a LIKE '%".$_GET["txtKeyword"]."%' 
	or sourcelocation_a LIKE '%".$_GET["txtKeyword"]."%' 
	or sourceport_a LIKE '%".$_GET["txtKeyword"]."%'	
	or sourceproduct_b LIKE '%".$_GET["txtKeyword"]."%'
	or sourcedevicename_b LIKE '%".$_GET["txtKeyword"]."%'
	or sourceipaddress_b LIKE '%".$_GET["txtKeyword"]."%'	
	or interface_a LIKE '%".$_GET["txtKeyword"]."%'
	or protocol_a LIKE '%".$_GET["txtKeyword"]."%') AND id = '$id_check' ";
	$objQuery1 = mysql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
	
	$strSQL2 = "SELECT * FROM sourcedestination WHERE (
	room_b LIKE '%".$_GET["txtKeyword"]."%'
	or row_b LIKE '%".$_GET["txtKeyword"]."%'
	or rack_b LIKE '%".$_GET["txtKeyword"]."%'
	or brand_b LIKE '%".$_GET["txtKeyword"]."%'
	or brands_b LIKE '%".$_GET["txtKeyword"]."%'
	or storage_b LIKE '%".$_GET["txtKeyword"]."%'
	or ports_b LIKE '%".$_GET["txtKeyword"]."%'
	or sourcelocation_b LIKE '%".$_GET["txtKeyword"]."%'
	or sourceport_b LIKE '%".$_GET["txtKeyword"]."%'	
	or sourceproduct_a LIKE '%".$_GET["txtKeyword"]."%'
	or sourcedevicename_a LIKE '%".$_GET["txtKeyword"]."%'
	or sourceipaddress_a LIKE '%".$_GET["txtKeyword"]."%'	
	or interface_b LIKE '%".$_GET["txtKeyword"]."%'
	or protocol_b LIKE '%".$_GET["txtKeyword"]."%') AND id = '$id_check' ";
	$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL2."]");
	
	
	
	
	
	?>
    
    
	<?
// ****************************  อันนี้ mysql_fetch_array  ----> LIKE _a  แต่โชว์ข้อมูล _b *********************
	if($objResult2 = mysql_fetch_array($objQuery2))
	{
	?>
	  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult2["id"];?>"><img src="image/1378293707_cog_edit.png" width="20" height="20"></a><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='phpMySQLDeleteRecord.php?id=<?=$objResult2["id"];?>';}"><img src="image/1378571326_button_cancel.png" width="20" height="20"></a></td>
    <td height="20" align="center"><?=$objResult2["sourcelocation_b"];?></td>
    <td height="20" align="center"><?=$objResult2["sourceport_b"];?></td>    
    <td height="20" align="center"><?=$objResult2["sourceproduct_a"];?></td>
    <td height="20" align="center"><?=$objResult2["sourcedevicename_a"];?></td>
    <td height="20" align="center"><?=$objResult2["sourceipaddress_a"];?></td>
    <td height="20" align="center"><?=$objResult2["interface_b"];?></td>
    <td height="20" align="center"><?=$objResult2["protocol_b"];?></td><td bgcolor="#FF0000">
    <td height="20" align="center"><?=$objResult2["sourceproduct_b"];?></td>
    <td height="20" align="center"><?=$objResult2["sourcedevicename_b"];?></td>
    <td height="20" align="center"><?=$objResult2["sourceipaddress_b"];?></td>
    <td height="20" align="center"><?=$objResult2["destinationport_b"];?></td>
    <td height="20" align="center"><?=$objResult2["destinationlocation_b"];?></td>
    <td height="20" align="center"><?=$objResult2["remark_b"];?></td>
  </tr>
	<?
	} //****************************ปิด LOOP LIKE A SHOW B
// ****************************  อันนี้ mysql_fetch_array  ----> LIKE _a  แต่โชว์ข้อมูล _b *********************
	if($objResult1 = mysql_fetch_array($objQuery1))
	{
	?>
	  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult1["id"];?>"><img src="image/1378293707_cog_edit.png" width="20" height="20"></a><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='phpMySQLDeleteRecord.php?id=<?=$objResult1["id"];?>';}"><img src="image/1378571326_button_cancel.png" width="20" height="20"></a></td>
    <td height="20" align="center"><?=$objResult1["sourcelocation_a"];?></td>
    <td height="20" align="center"><?=$objResult1["sourceport_a"];?></td>    
    <td height="20" align="center"><?=$objResult1["sourceproduct_b"];?></td>
    <td height="20" align="center"><?=$objResult1["sourcedevicename_b"];?></td>
    <td height="20" align="center"><?=$objResult1["sourceipaddress_b"];?></td>    
    <td height="20" align="center"><?=$objResult1["interface_a"];?></td>
    <td height="20" align="center"><?=$objResult1["protocol_a"];?></td><td bgcolor="#FF0000">
    <td height="20" align="center"><?=$objResult1["sourceproduct_a"];?></td>
    <td height="20" align="center"><?=$objResult1["sourcedevicename_a"];?></td>
    <td height="20" align="center"><?=$objResult1["sourceipaddress_a"];?></td>
    <td height="20" align="center"><?=$objResult1["destinationport_a"];?></td>
    <td height="20" align="center"><?=$objResult1["destinationlocation_a"];?></td>
    <td height="20" align="center"><?=$objResult1["remark_a"];?></td>
  </tr>
  </tbody> 
	<?
	} //****************************ปิด LOOP LIKE B SHOW A
	} //ปิด Loop _x
	?>
    </table>
	<?
	mysql_close($objConnect);
}
?>
</body>
</html>
 |  
              | 
 ประวัติการแก้ไข
 2013-11-12 11:01:37
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-12 10:57:18 | By :
                            lekjaengs |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | เรา order by...... อะไรไว้มันก็จะได้แบบนั้น....  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-12 11:15:53 | By :
                            apisitp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ไม่ได้อยู่ดีครับ ผมลองใส่ ORDER BY sourceport_a,sourceport_b ASC เเบบว่าให้มันค้นมาก่อนทั้ง _a และ _b เเล้วอยากให้มันมาเรียงลำดับทีหลังตอนเเสดงผลหน่คับหน่ะครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-12 11:29:05 | By :
                            lekjaengs |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ส่วนตัว : คิดว่า Order ได้ คอลัมภ์เดียว (ไม่รู้จริง ๆ )  
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-12 11:35:57 | By :
                            apisitp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | การขับรถยนต์ - จะว่ายากก็ยาก จะว่าง่ายก็ง่าย แต่สิ่งที่ยากกว่า คือ หาที่จอดรถ ... ดังนั้น เพื่อความสะดวก บางครั้งก็ต้องนั่งรถประจำทางบ้างก็ได้ครับ
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-12 14:17:39 | By :
                            apisitp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | สามารถใส่แบบเป็น group by ให้ _a และ _b มารวมกันก่อนได้ป่าวครับ แล้วค่อยให้เเสดงมาเรียงกันได้ไหม๊ครับ ลองเเล้วมันก็ไม่ได้   
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-12 14:54:06 | By :
                            lekjaengs |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | น่าจะใช้ศัพ sql อะไรสักอย่างครับที่จะให้ order by 2 ฟิลพร้อมๆกันได้  อันนี้ก็ลืมแหะ เดี๋ยวขอคิดก่อนครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-12 15:30:35 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | รวมตาราง แล้ว order by เข้าท่าแฮ่ะ.... 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-12 15:32:55 | By :
                            apisitp |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | $strSQL_x = "SELECT * FROM sourcedestination ORDER BY CONCAT(sourceport_a,sourceport_b)  ASC ";  //ปรับเรียงมากไปน้อยน้อยไปมากที่นี้
 ลองดูครับไม่รู้จะwork ไหมนะ ดีไม่ดีอาจจะ error ด้วยซ้ำ  ไปลอกฝรั่งมาอีกที 5 5 5
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-12 17:05:32 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | รันออกครับแต่ก็ยังเหมื๊อนเดิม ไม่มีอะไรเปลี่ยนไปหน่ะครับ 
 |  
              | 
 ประวัติการแก้ไข
 2013-11-12 17:09:43
 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-12 17:07:34 | By :
                            lekjaengs |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ช่วยผมทีคร๊าบ ตอนนี้ยังไม่ได้เลยหน่ะครับ code เดิมที่พี่ meannerss เขียน ค้นหาได้เเต่อยากให้ข้อมูลเรียงกันจากน้อยไปมากหน่ะครับที่ผมไฮไลค์ไว้ 
 
 Code (PHP)
 
 <html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
<script type="text/javascript" src="jquery-latest.js"></script> 
<script type="text/javascript" src="jquery.tablesorter.js"></script> 
<link href="themes/blue/style.css" rel="stylesheet" type="text/css">
</head>
<script type="text/javascript">
	$(document).ready(function() { 
		$("#myTable").tablesorter(); 
	}); 
</script>
<body>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
  <table width="599" id="large" class="tablesorter" border="1">
    <tr>
      <th>Keyword
      <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>">
      <input type="submit" value="Search"></th>
    </tr>
  </table>
</form>
<table id="myTable" class="tablesorter"> 
<thead> 
     
      <tr>
		<th width="58" align="center" valign="middle" bgcolor="#999999" ><strong>Edit|Del</strong></td>
            <th  width="164" height="26" align="center" valign="middle" bgcolor="#999999"><strong>Source Location</strong></td>
            <th width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source Port</strong></td>            
            <th width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source Product</strong></td>
            <th width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source Device Name</strong></td>
            <th width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source IP Address</strong></td>    
            <th width="64" align="center" valign="middle" bgcolor="#999999"><strong>Interface</strong></td>
            <th width="57" align="center" valign="middle" bgcolor="#999999"><strong>Protocol</strong></td>
            <th bgcolor="#FF0000"></td><th width="161" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Product</strong></td>
            <th width="132" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Device Name</strong></td>
            <th width="95" align="center" valign="middle" bgcolor="#999999" ><strong>Destination IP Address</strong></td>
            <th width="127" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Port</strong></td>
            <th width="165" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Location</strong></td>
            <th width="76" align="center" valign="middle" bgcolor="#999999" ><strong>Remark</strong></td>
	  </tr>
      </thead> 
<tbody> 
<?
if($_GET["txtKeyword"] != "")
	{
	$objConnect = mysql_connect("localhost","root","11223344") or die("Error Connect to Database");
	$objDB = mysql_select_db("destination");
	
	
	$strSQL_x = "SELECT * FROM sourcedestination ORDER BY sourceport_a  ASC ";  //ปรับเรียงมากไปน้อยน้อยไปมากที่นี้
	$objQuery_x = mysql_query($strSQL_x) or die ("Error Query [".$strSQL_x."]");
	
	while($objResult_x = mysql_fetch_array($objQuery_x))
	{
	$id_check=$objResult_x["id"];
	
	// Search By Name or Email
	$strSQL1 = "SELECT * FROM sourcedestination WHERE(
	room_a LIKE '%".$_GET["txtKeyword"]."%' 
	or row_a LIKE '%".$_GET["txtKeyword"]."%' 
	or rack_a LIKE '%".$_GET["txtKeyword"]."%' 
	or brand_a LIKE '%".$_GET["txtKeyword"]."%' 
	or brands_a LIKE '%".$_GET["txtKeyword"]."%' 
	or storage_a LIKE '%".$_GET["txtKeyword"]."%' 
	or port_a LIKE '%".$_GET["txtKeyword"]."%' 
	or ports_a LIKE '%".$_GET["txtKeyword"]."%' 
	or sourcelocation_a LIKE '%".$_GET["txtKeyword"]."%' 
	or sourceport_a LIKE '%".$_GET["txtKeyword"]."%'	
	or sourceproduct_b LIKE '%".$_GET["txtKeyword"]."%'
	or sourcedevicename_b LIKE '%".$_GET["txtKeyword"]."%'
	or sourceipaddress_b LIKE '%".$_GET["txtKeyword"]."%'	
	or interface_a LIKE '%".$_GET["txtKeyword"]."%'
	or protocol_a LIKE '%".$_GET["txtKeyword"]."%') AND id = '$id_check' ";
	$objQuery1 = mysql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
	
	$strSQL2 = "SELECT * FROM sourcedestination WHERE (
	room_b LIKE '%".$_GET["txtKeyword"]."%'
	or row_b LIKE '%".$_GET["txtKeyword"]."%'
	or rack_b LIKE '%".$_GET["txtKeyword"]."%'
	or brand_b LIKE '%".$_GET["txtKeyword"]."%'
	or brands_b LIKE '%".$_GET["txtKeyword"]."%'
	or storage_b LIKE '%".$_GET["txtKeyword"]."%'
	or ports_b LIKE '%".$_GET["txtKeyword"]."%'
	or sourcelocation_b LIKE '%".$_GET["txtKeyword"]."%'
	or sourceport_b LIKE '%".$_GET["txtKeyword"]."%'	
	or sourceproduct_a LIKE '%".$_GET["txtKeyword"]."%'
	or sourcedevicename_a LIKE '%".$_GET["txtKeyword"]."%'
	or sourceipaddress_a LIKE '%".$_GET["txtKeyword"]."%'	
	or interface_b LIKE '%".$_GET["txtKeyword"]."%'
	or protocol_b LIKE '%".$_GET["txtKeyword"]."%') AND id = '$id_check' ";
	$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL2."]");
	
	
	
	
	
	?>
    
    
	<?
// ****************************  อันนี้ mysql_fetch_array  ----> LIKE _a  แต่โชว์ข้อมูล _b *********************
	if($objResult2 = mysql_fetch_array($objQuery2))
	{
	?>
	  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult2["id"];?>"><img src="image/1378293707_cog_edit.png" width="20" height="20"></a><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='phpMySQLDeleteRecord.php?id=<?=$objResult2["id"];?>';}"><img src="image/1378571326_button_cancel.png" width="20" height="20"></a></td>
    <td height="20" align="center"><?=$objResult2["sourcelocation_b"];?></td>
    <td height="20" align="center"><?=$objResult2["sourceport_b"];?></td>    
    <td height="20" align="center"><?=$objResult2["sourceproduct_a"];?></td>
    <td height="20" align="center"><?=$objResult2["sourcedevicename_a"];?></td>
    <td height="20" align="center"><?=$objResult2["sourceipaddress_a"];?></td>
    <td height="20" align="center"><?=$objResult2["interface_b"];?></td>
    <td height="20" align="center"><?=$objResult2["protocol_b"];?></td><td bgcolor="#FF0000">
    <td height="20" align="center"><?=$objResult2["sourceproduct_b"];?></td>
    <td height="20" align="center"><?=$objResult2["sourcedevicename_b"];?></td>
    <td height="20" align="center"><?=$objResult2["sourceipaddress_b"];?></td>
    <td height="20" align="center"><?=$objResult2["destinationport_b"];?></td>
    <td height="20" align="center"><?=$objResult2["destinationlocation_b"];?></td>
    <td height="20" align="center"><?=$objResult2["remark_b"];?></td>
  </tr>
	<?
	} //****************************ปิด LOOP LIKE A SHOW B
// ****************************  อันนี้ mysql_fetch_array  ----> LIKE _a  แต่โชว์ข้อมูล _b *********************
	if($objResult1 = mysql_fetch_array($objQuery1))
	{
	?>
	  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult1["id"];?>"><img src="image/1378293707_cog_edit.png" width="20" height="20"></a><a href="JavaScript:if(confirm('Confirm Delete?')==true){window.location='phpMySQLDeleteRecord.php?id=<?=$objResult1["id"];?>';}"><img src="image/1378571326_button_cancel.png" width="20" height="20"></a></td>
    <td height="20" align="center"><?=$objResult1["sourcelocation_a"];?></td>
    <td height="20" align="center"><?=$objResult1["sourceport_a"];?></td>    
    <td height="20" align="center"><?=$objResult1["sourceproduct_b"];?></td>
    <td height="20" align="center"><?=$objResult1["sourcedevicename_b"];?></td>
    <td height="20" align="center"><?=$objResult1["sourceipaddress_b"];?></td>    
    <td height="20" align="center"><?=$objResult1["interface_a"];?></td>
    <td height="20" align="center"><?=$objResult1["protocol_a"];?></td><td bgcolor="#FF0000">
    <td height="20" align="center"><?=$objResult1["sourceproduct_a"];?></td>
    <td height="20" align="center"><?=$objResult1["sourcedevicename_a"];?></td>
    <td height="20" align="center"><?=$objResult1["sourceipaddress_a"];?></td>
    <td height="20" align="center"><?=$objResult1["destinationport_a"];?></td>
    <td height="20" align="center"><?=$objResult1["destinationlocation_a"];?></td>
    <td height="20" align="center"><?=$objResult1["remark_a"];?></td>
  </tr>
  </tbody> 
	<?
	} //****************************ปิด LOOP LIKE B SHOW A
	} //ปิด Loop _x
	?>
    </table>
	<?
	mysql_close($objConnect);
}
?>
</body>
</html>
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-25 21:23:21 | By :
                            lekjaengs |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | สักครู่ครับอยู่ด้านนอกแปปนึงนะครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-25 21:47:06 | By :
                            meannerss |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | order by field_a asc, field_b asc 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2013-11-26 13:52:09 | By :
                            PlaKriM |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 |  |