Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > สอบถามเรื่องการเรียงลำดับผลลัพธ์ในการค้นหาหน่อยครับ



 

สอบถามเรื่องการเรียงลำดับผลลัพธ์ในการค้นหาหน่อยครับ

 



Topic : 102477



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์




result

ผมอยากให้เวลาเรากดค้นหาแล้วข้อมูลที่แสดงออกมาตรง column ของ Source Port ให้มันเรียงจากน้อยไปมากหน่ะครับ

GigabitEthernet 0/24
GigabitEthernet 0/24
GigabitEthernet 3/1
GigabitEthernet 3/2
GigabitEthernet 3/3
GigabitEthernet 3

Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
  <table width="599" 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");
	// Search By Name or Email
	$strSQL = "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"]."%'
	or 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"]."%'	
	)";
	
	
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	?>
	<table width="600" border="1">
	  <tr>
		<td width="58" align="center" valign="middle" bgcolor="#999999" ><strong>Edit|Del</strong></td>
            <td  width="164" height="26" align="center" valign="middle" bgcolor="#999999"><strong>Source Location</strong></td>
            <td width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source Port</strong></td>
            <td width="64" align="center" valign="middle" bgcolor="#999999"><strong>Interface</strong></td>
            <td width="57" align="center" valign="middle" bgcolor="#999999"><strong>Protocol</strong></td>
            <td bgcolor="#FF0000"></td><td width="161" align="center" valign="middle" bgcolor="#999999" ><strong> Product</strong></td>
            <td width="132" align="center" valign="middle" bgcolor="#999999" ><strong>Device Name</strong></td>
            <td width="95" align="center" valign="middle" bgcolor="#999999" ><strong>IP Address</strong></td>
            <td width="127" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Port</strong></td>
            <td width="165" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Location</strong></td>
            <td width="76" align="center" valign="middle" bgcolor="#999999" ><strong>Remark</strong></td>
	  </tr>
	<?
	while($objResult = mysql_fetch_array($objQuery))
	{
	?>
	  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult["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=<?=$objResult["id"];?>';}"><img src="image/1378571326_button_cancel.png" width="20" height="20"></a></td>
    <td height="20" align="center"><?=$objResult["sourcelocation_a"];?></td>
    <td height="20" align="center"><?=$objResult["sourceport_a"];?></td>
    <td height="20" align="center"><?=$objResult["interface_a"];?></td>
    <td height="20" align="center"><?=$objResult["protocol_a"];?></td><td bgcolor="#FF0000">
    <td height="20" align="center"><?=$objResult["product_a"];?></td>
    <td height="20" align="center"><?=$objResult["devicename_a"];?></td>
    <td height="20" align="center"><?=$objResult["ipaddress_a"];?></td>
    <td height="20" align="center"><?=$objResult["destinationport_a"];?></td>
    <td height="20" align="center"><?=$objResult["destinationlocation_a"];?></td>
    <td height="20" align="center"><?=$objResult["remark_a"];?></td>
  </tr>
  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult["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=<?=$objResult["id"];?>';}"><img src="image/1378571326_button_cancel.png" width="20" height="20"></a></td>
    <td height="20" align="center"><?=$objResult["sourcelocation_b"];?></td>
    <td height="20" align="center"><?=$objResult["sourceport_b"];?></td>
    <td height="20" align="center"><?=$objResult["interface_b"];?></td>
    <td height="20" align="center"><?=$objResult["protocol_b"];?></td><td bgcolor="#FF0000">
    <td height="20" align="center"><?=$objResult["product_b"];?></td>
    <td height="20" align="center"><?=$objResult["devicename_b"];?></td>
    <td height="20" align="center"><?=$objResult["ipaddress_b"];?></td>
    <td height="20" align="center"><?=$objResult["destinationport_b"];?></td>
    <td height="20" align="center"><?=$objResult["destinationlocation_b"];?></td>
    <td height="20" align="center"><?=$objResult["remark_b"];?></td>
  </tr>
	<?
	}
	?>
	</table>
	<?
	mysql_close($objConnect);
}
?>
</body>
</html>




Tag : PHP, MySQL







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-11-08 12:56:51 By : lekjaengs View : 1197 Reply : 57
 

 

No. 1



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


เอามาเท่านี้ก็ได้ครับ ของเดิม
$strSQL = "SELECT * FROM sourcedestination WHERE ( อะไรก็ว่าไป )";


ปรับเป็น . . .

$strSQL = "SELECT * FROM sourcedestination WHERE ( อะไรก็ว่าไป ) ORDER BY sourceport_a ASC ";


sourceport_a = ชื่อฟิลที่ต้องการจัดเรียงตามนี้
ASC = น้อยไปมาก
DESC = มากไปน้อย






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 13:52:19 By : meannerss
 


 

No. 2



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 1 เขียนโดย : meannerss เมื่อวันที่ 2013-11-08 13:52:19
รายละเอียดของการตอบ ::

ขอบพระคุณมากๆเลยครับ ผมขอถามต่อได้ไหม๊ครับ ว่าถ้าอยากจะให้มันออกเฉพาะแถวที่มีคำที่เราค้นหา ผมต้องไปลบตรงไหนหรอครับ ขอบพระคุณมากๆอีกครั้งเลยครับ


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 14:13:47 By : lekjaengs
 

 

No. 3



โพสกระทู้ ( 5,105 )
บทความ ( 4 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


ลบแถวที่ไม่ต้องการครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 15:14:19 By : apisitp
 


 

No. 4



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


คำถามสุดท้ายครับพี่ๆ ส่วนอื่นๆ ผมได้หมดเเล้วครับ ต้องขอบคุณพี่ๆมากเลยครับ สุดท้าย คือผมอยากให้เวลาค้นหาคำว่า "Core Switch" แล้วข้อมูลในแถวที่มีคำว่า "Core Switch" ไม่ต้องแสดง ให้แสดงข้อมูลที่ไม่มี "Core Switch" แทนหน่ะครับ เช้น ค้นหา A ไม่ให้ A แสดง แสดงแต่ B หรือถ้าค้นหา B ไม่ให้ B แสดง แสดงแต่ A

ขอบพระคุณมากๆครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 17:55:00 By : lekjaengs
 


 

No. 5



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


NOT LIKE
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 18:53:02 By : PlaKriM
 


 

No. 6



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 5 เขียนโดย : PlaKriM เมื่อวันที่ 2013-11-08 18:53:02
รายละเอียดของการตอบ ::
ขอบคุณมากๆครับ แต่ผมลองใส่ NOT LIKE แล้วข้อมูลออกมาหมดเลยหนะครับ ผมต้องเขียนใส่ไว้ตรงไหนหรอครับ

Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
  <table width="599" 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");
	// Search By Name or Email
	$strSQL = "SELECT * FROM sourcedestination WHERE 
	(
	
		room_a NOT LIKE '%".$_GET["txtKeyword"]."%' 
	or row_a NOT LIKE '%".$_GET["txtKeyword"]."%' 
	or rack_a NOT LIKE '%".$_GET["txtKeyword"]."%' 
	or brand_a NOT LIKE '%".$_GET["txtKeyword"]."%' 
	or brands_a NOT LIKE '%".$_GET["txtKeyword"]."%' 
	or storage_a NOT LIKE '%".$_GET["txtKeyword"]."%' 
	or port_a NOT LIKE '%".$_GET["txtKeyword"]."%' 
	or ports_a NOT LIKE '%".$_GET["txtKeyword"]."%' 
	or sourcelocation_a NOT LIKE '%".$_GET["txtKeyword"]."%' 
	or sourceport_a NOT LIKE '%".$_GET["txtKeyword"]."%' 
	or interface_a NOT LIKE '%".$_GET["txtKeyword"]."%'
	or protocol_a NOT LIKE '%".$_GET["txtKeyword"]."%'
	or product_a NOT LIKE '%".$_GET["txtKeyword"]."%'
	or devicename_a NOT LIKE '%".$_GET["txtKeyword"]."%'
	or ipaddress_a NOT LIKE '%".$_GET["txtKeyword"]."%'
	or destinationport_a NOT LIKE '%".$_GET["txtKeyword"]."%'
	or destinationlocation_a NOT LIKE '%".$_GET["txtKeyword"]."%'
	or remark_a NOT LIKE '%".$_GET["txtKeyword"]."%'
	or room_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or row_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or rack_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or brand_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or brands_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or storage_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or ports_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or sourcelocation_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or sourceport_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or interface_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or protocol_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or product_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or devicename_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or ipaddress_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or destinationport_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or destinationlocation_b NOT LIKE '%".$_GET["txtKeyword"]."%'
	or remark_b NOT LIKE '%".$_GET["txtKeyword"]."%'	
	)";
	
	
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	?>
	<table width="600" border="1">
	  <tr>
		<td width="58" align="center" valign="middle" bgcolor="#999999" ><strong>Edit|Del</strong></td>
            <td  width="164" height="26" align="center" valign="middle" bgcolor="#999999"><strong>Source Location</strong></td>
            <td width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source Port</strong></td>
            <td width="64" align="center" valign="middle" bgcolor="#999999"><strong>Interface</strong></td>
            <td width="57" align="center" valign="middle" bgcolor="#999999"><strong>Protocol</strong></td>
            <td bgcolor="#FF0000"></td><td width="161" align="center" valign="middle" bgcolor="#999999" ><strong> Product</strong></td>
            <td width="132" align="center" valign="middle" bgcolor="#999999" ><strong>Device Name</strong></td>
            <td width="95" align="center" valign="middle" bgcolor="#999999" ><strong>IP Address</strong></td>
            <td width="127" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Port</strong></td>
            <td width="165" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Location</strong></td>
            <td width="76" align="center" valign="middle" bgcolor="#999999" ><strong>Remark</strong></td>
	  </tr>
	<?
	while($objResult = mysql_fetch_array($objQuery))
	{
	?>
	  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult["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=<?=$objResult["id"];?>';}"><img src="image/1378571326_button_cancel.png" width="20" height="20"></a></td>
    <td height="20" align="center"><?=$objResult["sourcelocation_a"];?></td>
    <td height="20" align="center"><?=$objResult["sourceport_a"];?></td>
    <td height="20" align="center"><?=$objResult["interface_a"];?></td>
    <td height="20" align="center"><?=$objResult["protocol_a"];?></td><td bgcolor="#FF0000">
    <td height="20" align="center"><?=$objResult["product_a"];?></td>
    <td height="20" align="center"><?=$objResult["devicename_a"];?></td>
    <td height="20" align="center"><?=$objResult["ipaddress_a"];?></td>
    <td height="20" align="center"><?=$objResult["destinationport_a"];?></td>
    <td height="20" align="center"><?=$objResult["destinationlocation_a"];?></td>
    <td height="20" align="center"><?=$objResult["remark_a"];?></td>
  </tr>
  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult["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=<?=$objResult["id"];?>';}"><img src="image/1378571326_button_cancel.png" width="20" height="20"></a></td>
    <td height="20" align="center"><?=$objResult["sourcelocation_b"];?></td>
    <td height="20" align="center"><?=$objResult["sourceport_b"];?></td>
    <td height="20" align="center"><?=$objResult["interface_b"];?></td>
    <td height="20" align="center"><?=$objResult["protocol_b"];?></td><td bgcolor="#FF0000">
    <td height="20" align="center"><?=$objResult["product_b"];?></td>
    <td height="20" align="center"><?=$objResult["devicename_b"];?></td>
    <td height="20" align="center"><?=$objResult["ipaddress_b"];?></td>
    <td height="20" align="center"><?=$objResult["destinationport_b"];?></td>
    <td height="20" align="center"><?=$objResult["destinationlocation_b"];?></td>
    <td height="20" align="center"><?=$objResult["remark_b"];?></td>
  </tr>
	<?
	}
	?>
	</table>
	<?
	mysql_close($objConnect);
}
?>
</body>
</html>



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 19:15:26 By : lekjaengs
 


 

No. 7



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


ค้น a เอาอันที่ไม่ไช่ a หรือ เอาอันที่ไม่มีส่วนประกอบของa ครับ

ถ้าใช้ not like คือไม่เอาอันที่มีส่วนประกอบของคำนี้ >>>> filde not like %text%
ถ้าใช้ <> (อ่านว่าไม่เท่ากับ ) คือไม่เอาอันที่เป็นคำนี้(แบบfulltext) >>>>> filde <> text
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 20:57:35 By : meannerss
 


 

No. 8



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 7 เขียนโดย : meannerss เมื่อวันที่ 2013-11-08 20:57:35
รายละเอียดของการตอบ ::
ก่อนอื่นต้องขอขอบคุณพี่มากๆเลยนะครับที่เสียสละเวลามาตอบให้ผม คือผมอยากให้เวลาเราค้นหา A แต่เอา B หรือ ค้น B แต่เอา A ครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 21:09:02 By : lekjaengs
 


 

No. 9



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


นั้นเหละครับ ถามต่อว่า ค้น 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
 


 

No. 10



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 9 เขียนโดย : meannerss เมื่อวันที่ 2013-11-08 21:24:31
รายละเอียดของการตอบ ::
แบบที่ 1 ครับ :: 1คำค้น "นายสม" นายสม และ นายสมชาย ไม่ต้องออกมา <<< ยังนี้ใช้ not like

คือผมไม่รู้จะเอา not like ไปใส่ไว้ตรงไหน เวลากดค้นหาเเล้วให้ คิวรี่ข้อมูลมาแสดงที่ไม่ใช่ทั้งนายสม และนายสมชาย หน่ะครับ ขอบคุณมากๆครับ ยกตัวอย่างได้เข้าใจมากๆเลยครับ แต่ผมขอเพิ่มเติมคือว่า


นายสมสุดหล่อ ถูกเก็บไว้อยู่ใน DB_A
และ นายสมชายโคตรจะรวย ถูกเก็บอยู่ใน DB_B

ถ้าค้นหาใน textbox ว่า นายสมสุดหล่อ ใน DB_A ข้อมูล นายสมชายโคตรจะรวย ถูกเก็บอยู่ใน DB_B จะแสดงขึ้นมา



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 21:52:34 By : lekjaengs
 


 

No. 11



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


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
 


 

No. 12



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 11 เขียนโดย : meannerss เมื่อวันที่ 2013-11-08 22:27:06
รายละเอียดของการตอบ ::
ตอนนี้ผมได้ส่วนหนึ่งเเล้วครับ ขอบคุณมากๆครับ



ประวัติการแก้ไข
2013-11-08 23:32:58
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-08 23:28:54 By : lekjaengs
 


 

No. 13

Guest


พื้นฐานคิวรี่ หาอ่านเพิ่มเติมนะ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-09 07:27:53 By : telesyn
 


 

No. 14



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 13 เขียนโดย : telesyn เมื่อวันที่ 2013-11-09 07:27:53
รายละเอียดของการตอบ ::
ได้เลยครับ ขอบพระคุณมากๆครับ สำหรับคำแนะนำคับ ตอนนี้ติดปัญหาอีกเเล้วครับ คือจากฐานข้อมูลของผมเป็นแบบนี้ครับ

insert

ผมค้นหาข้อมูล A ที่มี A1 A2 A3 A4 เก็บอยู่ ค้นหาตัวใดตัวหนึ่งในข้อมูล A ข้อมูลที่เป็นของ B ก็คือ B1 B2 B3 B4 จะขึ้นมาแสดงเเทน


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-09 13:22:52 By : lekjaengs
 


 

No. 15



โพสกระทู้ ( 5,105 )
บทความ ( 4 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


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
 


 

No. 16



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 15 เขียนโดย : apisitp เมื่อวันที่ 2013-11-09 13:31:01
รายละเอียดของการตอบ ::
ไม่ได้อะครับ คือข้อมูลมันอยู่ในแถวเดียวกันครับ หัวกับ หาง หัวคือ A หางคือ B คือถ้าเราค้นหาอะไรไปสักอย่างไปติดที่หัวก็คือ A ข้อมูลที่เป็นหางที่เป็น B จะถูกเรียกขึ้นมาแสดงแทนครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-09 13:43:29 By : lekjaengs
 


 

No. 17



โพสกระทู้ ( 5,105 )
บทความ ( 4 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


เหอะ ๆ มีแต่เรื่องยาก ๆ เน๊อะ...
แล้วไม ไม่แยกเก็บไปเลยล่ะ
ถ้ายังไม่ได้ใช้ระบบจริง
น่าจะแยกทันอยู่ ฮิ้วววววววววววววววววว
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-09 14:12:31 By : apisitp
 


 

No. 18



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


รู้สึกจะออกแบบฐานข้อมูลแปลกๆนะครับ ลองเอา DB มากางให้เพื่อนๆสมาชิกช่วยกันคิด น่าจะได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-09 14:13:37 By : meannerss
 


 

No. 19



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


insert

ฐานข้อมูล ผมทำออกมาเป็นก้อนเดียว เเต่ยาวๆหน่ะครับ มันได้ไหม๊ครับ ครั้งนี้จะเป็นครั้งสุดท้ายที่ออกเเบบฐานข้อมูลได้เกรียนเเบบนี้หน่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-09 14:32:31 By : lekjaengs
 


 

No. 20



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ผมลองอัพฐานข้อมูลแล้วครับ ค้นข้อมูลไม่ว่าจะอยู่ตรงไหน ให้เเสดงข้อมูลที่ตรงกันข้าม มันทำอย่างไงหรอครับ สมมุติ ค้นเจอคำว่า Firewall ไปอยู่ _b ให้ข้อมูลที่เป็น _a แสดง งงจุงๆ ช่วยทีครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-09 22:58:14 By : lekjaengs
 


 

No. 21



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


ถามชัดๆเลยว่า .. . .
1. _a และ _b อยู่ ในตารางเดียวกัน หรือ คนละตารางแต่ DB เดียวกัน หรือ อยู่คนละ DBกันเลย


ประวัติการแก้ไข
2013-11-09 23:22:59
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-09 23:19:45 By : meannerss
 


 

No. 22



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 21 เขียนโดย : meannerss เมื่อวันที่ 2013-11-09 23:19:45
รายละเอียดของการตอบ ::
_a และ _b อยู่ ในตารางเดียวกันครับ ชื่อตารางคือ sourcedestination โดยตารางจะเก็บ _a และ _b ไว้ยาวๆเเบบนั้นเลยครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 00:00:01 By : lekjaengs
 


 

No. 23



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


เหอๆๆๆ แบบนั้นก็ไม่ต้องคิดมากครับ ตรรกกะคิดมาผิดทั้งหมดนะ

ลักษณะงานน่าจะเป็นแบบนี้ไช่ไหมครับ
ผู้ใช้งานรู้แต่ข้อมุล A ซึ่งเค้าจะไม่รู้ข้อมูลชนิด B ดังนั้น... ตอนSearch เค้าจึงต้องSearch ข้อมูลประเภท A แต่เราจะโชว์ B ให้เห็น ถูกไหมครับ ถ้าผมคิดถูกมันต้องเป็นแบบนี้
Search A เอา A นั้นเหละ แต่โชว์ข้อมูล B เฉยๆ


ดังนั้นใช้ LIKE แต่่ส่วนการ mysql_fetch_array เรา เอาแค่ข้อมูล _b มาแสดงเฉยๆไม่มีอะไรยุ่งยากเลย :)
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 00:22:34 By : meannerss
 


 

No. 24



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 23 เขียนโดย : meannerss เมื่อวันที่ 2013-11-10 00:22:34
รายละเอียดของการตอบ ::
เกือบจะใช่เเล้วพี่ คือผู้ใช้งานจะไม่รู้นะครับ ว่าข้อมูลอยู่ใน A หรือ B เพียงแต่ว่า ถ้าค้นหาเเล้วไปตกตรง A ไม่ก็ตกตรง B มันจะโชว์ข้อมูลตรงกันข้ามเท่านั้นหน่ะครับ ผมต้องตัดส่วนไหนเเล้วเพิ่มส่วนไหนหรอ

แบบนี้ครับ

ค้นหาเจอใน A เอา A มาแต่โชว์ B
ค้นหาเจอใน B เอา B มาแต่โชว์ A



ประวัติการแก้ไข
2013-11-10 00:29:33
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 00:28:25 By : lekjaengs
 


 

No. 25



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


ทำได้ครับ...........
***แต่มีเงื่อนใขว่าใน 1 เรคคอร์ด(แถว)ของข้อมูลนั้นๆ _A และ _B ต้องไม่เหมือนกัน . . . . ไม่เช่นนั้นจะออกมาทั้งคู่แน่นอน

1. ทำสองคิวรี่ครับ

Code (PHP)
$strSQL1 = "SELECT * FROM sourcedestination WHERE ( room _a ทั้งหมด Like อะไรก็ว่ากันไป)";
$objQuery1 = mysql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
$strSQL2 = "SELECT * FROM sourcedestination WHERE ( room _b ทั้งหมด Like อะไรก็ว่ากันไป)";
$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL2."]");


2. โชว์หัวตารางตามปกติ

<table width="600" border="1"> <tr> <td width="58" align="center" valign="middle" bgcolor="#999999" ><strong>Edit|Del</strong></td> <td width="164" height="26" align="center" valign="middle" bgcolor="#999999"><strong>Source Location</strong></td> <td width="126" align="center" valign="middle" bgcolor="#999999"><strong>Source Port</strong></td> <td width="64" align="center" valign="middle" bgcolor="#999999"><strong>Interface</strong></td> <td width="57" align="center" valign="middle" bgcolor="#999999"><strong>Protocol</strong></td> <td bgcolor="#FF0000"></td><td width="161" align="center" valign="middle" bgcolor="#999999" ><strong> Product</strong></td> <td width="132" align="center" valign="middle" bgcolor="#999999" ><strong>Device Name</strong></td> <td width="95" align="center" valign="middle" bgcolor="#999999" ><strong>IP Address</strong></td> <td width="127" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Port</strong></td> <td width="165" align="center" valign="middle" bgcolor="#999999" ><strong>Destination Location</strong></td> <td width="76" align="center" valign="middle" bgcolor="#999999" ><strong>Remark</strong></td> </tr>


3. mysql_fetch_array 2 รอบสร้าง <tr> 2 รอบนั้นเอง... รอบแรกเป็นของ
รอบแรก -<tr> LIKE _a ทั้งหมดซึ่งจะโชว์ รายละเอียดของ b
รอบสอง -<tr> LIKE _b ทั้งหมดซึ่งจะโชว์ รายละเอียดของ a




<?
// ****************************  อันนี้ mysql_fetch_array  ----> LIKE _a  แต่โชว์ข้อมูล _b *********************
	while($objResult1 = mysql_fetch_array($objQuery1))
	{
	?>
	  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult["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=<?=$objResult["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 _b  แต่โชว์ข้อมูล _a *********************
	while($objResult2 = mysql_fetch_array($objQuery2))
	{
	?>
	  <tr align="center" valign="middle" bgcolor="<?=$bg?>">
    <td height="20" align="center"><a href="phpMySQLEditRecordForm.php?id=<?=$objResult["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=<?=$objResult["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>
	<?
	} //****************************ปิด LOOP LIKE B SHOW A
	?>



ประวัติการแก้ไข
2013-11-10 01:04:01
2013-11-10 01:05:23
2013-11-10 01:07:09
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 00:59:41 By : meannerss
 


 

No. 26



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 25 เขียนโดย : meannerss เมื่อวันที่ 2013-11-10 00:59:41
รายละเอียดของการตอบ ::
ผมได้เเล้วพี่ ขอบพระคุณมากๆเลยครับ เล่นเอาซะยาวเลย ตกลงผมพูดผิด ทำให้พี่เข้าใจผิดเองใช่ไหม๊ครับ ขอบพระคุณจริงๆครับ ทุกคอมเม้นผมกด + ให้หมดเลยครับ พี่เคยดีใจอะไรขนาดนีี้ไหม๊ครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 01:15:46 By : lekjaengs
 


 

No. 27



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 26 เขียนโดย : lekjaengs เมื่อวันที่ 2013-11-10 01:15:46
รายละเอียดของการตอบ ::
ครับไม่เป็นไร สนุกดี 55 แต่
**จะมีปัญหาในการ ORDER BY นะครับ คือข้อมูลที่ fetch จาก Like a จะโชว์ก่อน ข้อมูลที่มาจาก Like b ทั้งหมด
** อาจเกิดปัญหาโชว์ข้อมูลซ้ำซ้อนได้ กรณีที่ ในเรคคอร์ดนั้นๆ มี ฟิลใน _a ดันไปเหมือนกับ _b

วิธีแก้ ปัญหานี้เกิดจากการออกแบบฐานข้อมูลที่ผิดพลาด อก้โดยขจัดการซ้ำซ้อนของข้อมูล โดยนอมอลไลเซชั่นและออกแบบฐานข้อมูลมาใหม่ แยก _a / _b ออกจากกันเป็นคนละ table ไปเลย จากนั้นใช้ pk เป็นตัวผูกเอนติตี้เข้าด้วยกัน

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 01:27:08 By : meannerss
 


 

No. 28



โพสกระทู้ ( 5,105 )
บทความ ( 4 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


ติดตามเหมือนกัน : กว่าจะจบ...555+
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 08:24:58 By : apisitp
 


 

No. 29



โพสกระทู้ ( 1,569 )
บทความ ( 2 )



สถานะออฟไลน์
Twitter Facebook Blogger

ตอบความคิดเห็นที่ : 27 เขียนโดย : meannerss เมื่อวันที่ 2013-11-10 01:27:08
รายละเอียดของการตอบ ::
ใช้พวก array_unique ก็ได้ครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 08:40:19 By : itpcc
 


 

No. 30



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 27 เขียนโดย : meannerss เมื่อวันที่ 2013-11-10 01:27:08
รายละเอียดของการตอบ ::
นั่นซิครับผมก็พยายามใส่ Order by มันไม่เรียงให้ผม ผมลองใช้ tableshorter ก็ยังไม่เรียง กำกำ



ประวัติการแก้ไข
2013-11-10 10:41:41
2013-11-10 11:19:39
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 10:20:55 By : lekjaengs
 


 

No. 31



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


อาจมีเทคนิค SQL ที่ดีกว่านี้ครับ อาจจะมีศัพทืแปลกๆที่เอาไว้ใช้งานประเภทนี้ ที่เราไม่ค่อยเห็นมากนักในชีวิตประจำวัน.. .....รอท่านอื่นๆครับ ผมนึกวิธีไม่ออกจริงๆนอกจากวิธีนี้ 555
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 11:33:21 By : meannerss
 


 

No. 32



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 31 เขียนโดย : meannerss เมื่อวันที่ 2013-11-10 11:33:21
รายละเอียดของการตอบ ::
ครับพี่ ขอบพระคุณมากๆเลยนะครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 16:03:35 By : lekjaengs
 


 

No. 33



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


อาจจะต้องถามลูกพี่ผม คุณ 9713 เค้าอาจจะมีวิธีเทพๆกว่านี้ครับ รายนั้นไม่ธรรมดา
แต่ต้องถามในจังหวะเวลาที่เป็นฤกงามยามดีนะ ไม่เช่นนั้นจะได้ปริศนาธรรมมาแทน
ซึ่งมันจะเป็นอะไรที่ลึกซึ้งกว่าโค้ดหลายเท่าตัวนัก
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 16:20:38 By : meannerss
 


 

No. 34



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 33 เขียนโดย : meannerss เมื่อวันที่ 2013-11-10 16:20:38
รายละเอียดของการตอบ ::
ช่วงเวลาไหนหรอครับ ที่เป็นฤกงามยามดี 555+

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 16:37:22 By : lekjaengs
 


 

No. 35



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


ผมคิดออกละครับ ขอ Full code โพสส์มาอีกทีใช้ได้แน่ๆ มีแนวคิดมาดังนี้

เดิม
looper

ใหม่
looper2
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 17:03:34 By : meannerss
 


 

No. 36



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ยังไงหรอครับ ผมตามพี่ไม่ทันตลอด

ตอบความคิดเห็นที่ : 35 เขียนโดย : meannerss เมื่อวันที่ 2013-11-10 17:03:34
รายละเอียดของการตอบ ::
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>


<?
if($_GET["txtKeyword"] != "")
	{
	$objConnect = mysql_connect("localhost","root","11223344") or die("Error Connect to Database");
	$objDB = mysql_select_db("destination");
	// 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"]."%')";
	
	
	
	$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"]."%')";
	$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 *********************
	while($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 *********************
	while($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
	?>
    </table>
	<?
	mysql_close($objConnect);
}
?>
</body>
</html>





ประวัติการแก้ไข
2013-11-10 17:17:41
2013-11-10 17:18:12
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 17:16:31 By : lekjaengs
 


 

No. 37



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


ลองใหม่ดูอาจจะเออเร่อนะ

<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
 


 

No. 38



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 37 เขียนโดย : meannerss เมื่อวันที่ 2013-11-10 17:28:34
รายละเอียดของการตอบ ::
เรียงเเล้วครับพี่ แต่เหมือนว่าผมจะพิมพ์อะไรผิดใน Loop ไปป่ะครับ มันถึงขึ้นแบบนี้

ภภภ

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>


<?
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 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:38:08 By : lekjaengs
 


 

No. 39



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


อ่อลืมเอาหัวข้อออกไปนอก Loop ครับ

ยกบรรทัดที่ 82 - 99 ไปไว้บรรทัดที่ 23 ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 17:40:58 By : meannerss
 


 

No. 40



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 39 เขียนโดย : meannerss เมื่อวันที่ 2013-11-10 17:40:58
รายละเอียดของการตอบ ::
ได้หมดเเล้วครับพี่ ขอบพระคุณพี่มากๆเลยครับ ไม่รู้จะตอบเเทนอย่างไรดี

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-10 17:49:12 By : lekjaengs
 


 

No. 41



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


มาปรึกษาพี่ๆอีกเเล้วครับ ตอนเเรก ได้หมดเเล้วครับ เพียงแต่ว่า จะทำอย่างไรถ้าข้อมูลเยอะๆเเล้วมันไม่เรียงให้หน่ะครับ ถ้าข้อมูลน้อยๆมันจะเรียงครับ ตามที่ผม ไฮไลค์ไว้ ผมต้องเพิ่มคำสั่งอย่างไรให้ตอนค้นหาทั้งหมดเรียกมาโชว์เเล้วค่อยจัดเรียงหรอครับ

insert

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
 


 

No. 42



โพสกระทู้ ( 5,105 )
บทความ ( 4 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


เรา order by...... อะไรไว้มันก็จะได้แบบนั้น....
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-12 11:15:53 By : apisitp
 


 

No. 43



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ไม่ได้อยู่ดีครับ ผมลองใส่ ORDER BY sourceport_a,sourceport_b ASC เเบบว่าให้มันค้นมาก่อนทั้ง _a และ _b เเล้วอยากให้มันมาเรียงลำดับทีหลังตอนเเสดงผลหน่คับหน่ะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-12 11:29:05 By : lekjaengs
 


 

No. 44



โพสกระทู้ ( 5,105 )
บทความ ( 4 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


ส่วนตัว : คิดว่า Order ได้ คอลัมภ์เดียว (ไม่รู้จริง ๆ )
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-12 11:35:57 By : apisitp
 


 

No. 45



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 44 เขียนโดย : apisitp เมื่อวันที่ 2013-11-12 11:35:57
รายละเอียดของการตอบ ::
ครัฟๆ คือผมไม่รู้ว่าผมอธิบายถูกหรือป่าว แบบว่า ให้ทั้ง 2 ฟิลออกมาก่อนเเล้วค่อยมาจัดเรียงอีกทีหน่ะครับ คือตอนนี้มันเรียงเเล้วครับ เเต่ถ้าข้อมูลเยอะๆ มันจะไม่เรียงหน่ะครับ งงเเตกเลย 555 ยากจุงเบย

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-12 14:05:18 By : lekjaengs
 


 

No. 46



โพสกระทู้ ( 5,105 )
บทความ ( 4 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


การขับรถยนต์ - จะว่ายากก็ยาก จะว่าง่ายก็ง่าย แต่สิ่งที่ยากกว่า คือ หาที่จอดรถ ...
ดังนั้น เพื่อความสะดวก บางครั้งก็ต้องนั่งรถประจำทางบ้างก็ได้ครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-12 14:17:39 By : apisitp
 


 

No. 47



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


สามารถใส่แบบเป็น group by ให้ _a และ _b มารวมกันก่อนได้ป่าวครับ แล้วค่อยให้เเสดงมาเรียงกันได้ไหม๊ครับ ลองเเล้วมันก็ไม่ได้
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-12 14:54:06 By : lekjaengs
 


 

No. 48



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


น่าจะใช้ศัพ sql อะไรสักอย่างครับที่จะให้ order by 2 ฟิลพร้อมๆกันได้ อันนี้ก็ลืมแหะ เดี๋ยวขอคิดก่อนครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-12 15:30:35 By : meannerss
 


 

No. 49



โพสกระทู้ ( 5,105 )
บทความ ( 4 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


รวมตาราง แล้ว order by เข้าท่าแฮ่ะ....
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-12 15:32:55 By : apisitp
 


 

No. 50



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


$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
 


 

No. 51



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


รันออกครับแต่ก็ยังเหมื๊อนเดิม ไม่มีอะไรเปลี่ยนไปหน่ะครับ


ประวัติการแก้ไข
2013-11-12 17:09:43
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-12 17:07:34 By : lekjaengs
 


 

No. 52



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


เหมือนจะคิดออกประเด็นตอนนี้คือ ...
ORDER BY 2 ฟิล sourceport_a และ sourceport_b . . . อันไหนน้อยกว่า(ASC)ขึ้นก่อน ยังไงนะ มันต้องมีศัพท์อะไรสักอย่างรอท่านอื่นครับ . . .

ลอง AND ยังครับไม่รู้จะได้ไหมนะ 5 5

ORDER BY sourceport_a AND sourceport_b ASC



ประวัติการแก้ไข
2013-11-12 17:33:47
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-12 17:24:12 By : meannerss
 


 

No. 53



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 52 เขียนโดย : meannerss เมื่อวันที่ 2013-11-12 17:24:12
รายละเอียดของการตอบ ::
ลองใส่เเละเปลี่ยนตามพี่ทั้ง 2 วิธีเเล้วก็ยังเหมือนเดิมครับ ไม่เปลี่ยนแปลง

insert



ประวัติการแก้ไข
2013-11-12 18:40:44
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-12 17:53:12 By : lekjaengs
 


 

No. 54



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ช่วยผมทีคร๊าบ ตอนนี้ยังไม่ได้เลยหน่ะครับ 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
 


 

No. 55



โพสกระทู้ ( 1,666 )
บทความ ( 0 )



สถานะออฟไลน์


สักครู่ครับอยู่ด้านนอกแปปนึงนะครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-25 21:47:06 By : meannerss
 


 

No. 56



โพสกระทู้ ( 11,835 )
บทความ ( 10 )

สมาชิกที่ใส่เสื้อไทยครีเอท Hall of Fame 2012

สถานะออฟไลน์


order by field_a asc, field_b asc
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-11-26 13:52:09 By : PlaKriM
 


 

No. 57



โพสกระทู้ ( 42 )
บทความ ( 0 )



สถานะออฟไลน์


ตอบความคิดเห็นที่ : 56 เขียนโดย : PlaKriM เมื่อวันที่ 2013-11-26 13:52:09
รายละเอียดของการตอบ ::
ลองแล้วครับ แต่ก็ยังไม่เรียงให้ครับ แสดงรูป Output ที่ผมไฮไลค์ไว้ครับ ปวดตับเลยครับ

source



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, sourceport_b 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-26 14:41:31 By : lekjaengs
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : สอบถามเรื่องการเรียงลำดับผลลัพธ์ในการค้นหาหน่อยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่