|
 |
|
ต้องการเพิ่ม sort หลังจากคนหาห้อมูล คือต้องการเพิ่ม sort หลังจากคนหาห้อมูล ให้เรียงข้อมูล ตาม ไอดี ชื่อ .......ตามรูปครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
<form name="form1" method="post" action="searchall.php">
ชื่อที่ต้องการค้นหา <input type="text" name="keyword" value="<? echo"$keyword"; ?>">
จาก Filed
<select name="fields">
<option value="<?echo "$fields"; ?>"></option>
<option value="id">รหัสสินค้า</option>
<option value="name">สินค้า</option>
<option value="brand">ยี่ห้อ</option>
<option value="detail">รายละเอียด</option>
<option value="price">ราคา</option>
<option value="warranty">ประกัน</option>
<option value="date">วันที่นำเข้า</option>
<option value="pcode">หมวดสินค้า</option>
</select>
<input type="submit" name="Submit" value="ค้นหา">
</form>
<hr>
<?
if (empty($keyword) or empty($fields))
{
echo"กรุณาเลือกรายการค้นหา ด้วยครับ";
exit();
}
else
{
$host="localhost";
$username="root";
$password="1234";
$db="data_computer";
$tb="product";
mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
$cs1 = "SET character_set_results=tis620";
mysql_query($cs1) or die('Error query: ' . mysql_error());
$cs2 = "SET character_set_client = tis620";
mysql_query($cs2) or die('Error query: ' . mysql_error());
$cs3 = "SET character_set_connection = tis620";
mysql_query($cs3) or die('Error query: ' . mysql_error());
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้"); /* ทำการเลือกฐานข้อมูลก่อน */
$sql="SELECT * FROM $tb where $fields like '%$keyword%' order by id asc";
$db_query=mysql_db_query($db,$sql);
$num_rows=mysql_num_rows($db_query); /* นับ Reccord ที่พบ */
if(empty($num_rows)) /* ตรวจสอบว่ามีอยู่หรือยัง */
{
echo"<center><br>ไม่พบข้อมูล <b>$keyword</b> จาก Filed <b>$fields <b> </center>";
exit();
}
else
{
?>
<div align="center">
<? echo " แสดงรายการค้นหา <b>$keyword</b> จาก Filed <b>$fields</b> พบ <b>$num_rows</b> Reccord "; ?>
<br>
<br>
</div>
<table width="95%"border="0"align="center" cellpadding="2" cellspacing="2" bordercolor="#FFFFFF">
<td width="8%" bordercolor="#FFFFFF" bgcolor="#999933"><div align="center" class="style7">รหัสสินค้า</div></td>
<td width="8%" bordercolor="#FFFFFF" bgcolor="#999933"><div align="center" class="style7">สินค้า</div></td>
<td width="18%" bordercolor="#FFFFFF" bgcolor="#999933"><div align="center" class="style7">ยี่ห้อ</div></td>
<td width="30%" bordercolor="#FFFFFF" bgcolor="#999933"><div align="center" class="style7">รายละเอียด</div></td>
<td width="8%" bordercolor="#FFFFFF" bgcolor="#999933"><div align="center" class="style7">ราคา</div></td>
<td width="6%" bordercolor="#FFFFFF" bgcolor="#999933"><div align="center" class="style7">ประกัน</div></td>
<td width="11%" bordercolor="#FFFFFF" bgcolor="#999933"><div align="center" class="style7">วันที่นำเข้า</div></td>
<td width="10%" bordercolor="#FFFFFF" bgcolor="#999933"><div align="center" class="style7">หมวดสินค้า</div></td>
</tr>
<?
$i=1;
while ( $result = mysql_fetch_array($db_query))
{
if ($i%2==0) echo "<tr bgcolor=#B5B5B5>";
else echo "<tr bgcolor=#00BFFF>";
echo "<td class=style4>",$result[id],"</td>";
echo "<td class=style4>",$result[name],"</td>";
echo "<td class=style4>",$result[brand],"</td>";
echo "<td class=style4>",$result[detail],"</td>";
echo "<td align=right class=style4>",$result[price],"</td>";
echo "<td align=center class=style4>",$result[warranty],"</td>";
echo "<td class=style4>",$result[date],"</td>";
echo "<td align=center class=style4>",$result[pcode],"</td>
</tr>";
$i++;
}
?>
</table>
<tr>
<td colspan="9" align="center"><p align="center"> </p>
<p align="center"><img src="image/icon_printer.gif" width="38" height="33" align="middle" style="CURSOR : hand" onClick="window.print();"></p>
<p align="center"><span class="style4">สั่งพิมพ์</span>์</p>
<div align="left"></div> </td>
</tr>
?>
คือต้องการเพิ่ม sort หลังจากคนหาห้อมูล ให้เรียงข้อมูล ตาม ไอดี ชื่อ .......ตามรูปครับ
รูปภาพ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-02-13 08:54:14 |
By :
queenta |
View :
1194 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
พอเข้าใจอยู่ว่าต้องการทำอะไร แต่ไม่ค่อยว่างด้วยแหะ
แนะนำให้ลองทำส่งค่าแบบ GET แล้วอยากจะ Sort ตัวไหนก็ทำลิ้งค์ส่งค่าสำหรับทำ ORDER BY ของแต่ละลิ้งค์แล้วทำการเช็คค่าที่ส่งมาเอาไปเพิ่มในตอนคิวรี่
งงม่ะ (ผมเองก็งงๆ แต่ผมก็ทำแบบนี้ล่ะ) ถ้างงรอคนว่างๆเทพๆ มาตอบล่ะกันงิ
|
 |
 |
 |
 |
Date :
2009-02-13 09:22:47 |
By :
zankumuro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2009-02-13 10:32:03 |
By :
p_latplee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุงคับ
|
 |
 |
 |
 |
Date :
2009-02-13 12:59:10 |
By :
queenta |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|