|
|
|
ช่วยดูโค้ดให้หน่อยค่ะ นี่คือฟอร์มค้นหาค่ะจะพอมีวิธีเขียนโค้ดค้นหาหลายเงื่อนไขแบบนี้ป่ะค่ะ |
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2010-02-25 08:36:13 |
By :
axiom |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style121 {color: #003300;
font-size: 13px;
font-weight: bold;
}
.style123 {color: #000000}
.style13 {font-family: tahoma}
.style130 { color: #003300;
font-family: tahoma;
font-size: 13px;
font-weight: bold;
}
.style14 {
color: #333333;
font-weight: bold;
font-size: 14px;
}
a:link {
color: #000000;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #000000;
}
a:hover {
text-decoration: none;
color: #000000;
}
a:active {
text-decoration: none;
color: #000000;
}
.style15 {
font-size: 40px;
font-weight: bold;
font-family: "Courier New", Courier, monospace;
}
-->
</style>
</head>
<body>
<form method="post" action="product.php">
<div align="center">
<table width="223" height="66" border="1">
<tr>
<td colspan="6"><div align="center"><span class="style15">PRODUCT</span></div></td>
</tr>
</table>
<p> <br />
<br />
<select name="field_search">
<option value="id_product">ID Product</option>
<option value="name_product">Name Product</option>
<option value="amount">Amount</option>
<option value="start_date">Start Date</option>
<option value="price">Price</option>
</select>
<input type="text" name="search" size="15" />
<input name="submit" type="submit" value="SEARCH" />
</p>
<p><br />
</p>
</div>
</form>
<?php
include ("../connection/connect.php");
//$data_goat_group = "data_goat_group"; //ชื่อตาราง
// คำสั่ง SQL และสั่งให้ทำงาน
$sql = "select * from product_data where $field_search like '%$search%'"; // กำหนดคำสั่ง SQL เพื่อแสดงข้อมูล
$dbquery = mysql_db_query($dbname, $sql);
//echo '$sql ='.$sql .'<br>';
// หาจำนวนเรกคอร์ดข้อมูลในตาราง
@$num_rows = mysql_num_rows($dbquery);
// หาจำนวนฟิลด์ในตาราง
@$num_fields = mysql_num_fields($dbquery);
echo "<br>";
echo "<br>";
echo "<Font color=white> ------------------------------------------- </Font><Font color=#000000 size=3> Search is Complete. Result word </Font><Font color=red size=3>".$search." </Font><Font color=#000000 size=3>field </Font><Font color=red size=3>".$field_search." </Font><Font color=black>-</Font>";
echo "<Font color=#000000 size=3>found <Font color=red size=3>". $num_rows." reccord";
echo "<br>";
echo "<br>";
echo "<br>";
echo "<Table border=1>";
echo "<Tr>";
echo "</Table>";
//end While
//mysql_close(); // ปิดการเชื่อมต่อ
?>
<table width="718" height="128" border="1" align="center" cellpadding="1" cellspacing="0">
<tr bgcolor="#D9F4B0">
<td height="48" colspan="8" align="center" bordercolor="#D9F4B0"><a href="addpro.php"><span class="style13 style14 style123">Insert Product</span></a></td>
</tr>
<tr>
<td width="92" height="34" align="center" bordercolor="#D9F4B0" bgcolor="#FFFFFF"><div align="center" class="style13 style121">ID Product</div>
<div align="center"></div></td>
<td width="99" align="center" bordercolor="#D9F4B0" bgcolor="#FFFFFF"><div align="center" class="style130">Product</div></td>
<td width="122" align="center" bordercolor="#D9F4B0" bgcolor="#FFFFFF"><div align="center" class="style13 style121">Amount</div></td>
<td width="88" bordercolor="#D9F4B0" bgcolor="#FFFFFF"><div align="center" class="style13 style121">Start Date</div></td>
<td width="117" bordercolor="#D9F4B0" bgcolor="#FFFFFF"><div align="center"><span class="style13 style121">Price</span></div></td>
<td width="85" bordercolor="#D9F4B0" bgcolor="#FFFFFF"><div align="center" class="style13 style121">Edit</div></td>
<td width="85" colspan="2" bordercolor="#D9F4B0" bgcolor="#FFFFFF"><div align="center" class="style13 style121">Drop</div></td>
</tr>
<?php
/*******************************************
for($i=1;$i<=$num;$i++)
{
$row = mysql_fetch_array($query);
*****************************************/
while(@$rs = mysql_fetch_array($dbquery)){
$id_product = $rs[id_product];
$name_product = $rs[name_product];
$amount = $rs[amount];
$start_date = $rs[start_date];
// $tyear = substr($start_date,0,4);
// $tmonth = substr($start_date,5,2);
// $tday = substr($start_date,8,2);
$start_date = $rs[start_date];
$price = $rs[price];
?>
<tr>
<td height="44" bordercolor="#D9F4B0" bgcolor="#E9F3F3"><div align="center" class="style123 style122 style13"><strong><?php echo $id_product;?></strong></div>
<div align="center"></div></td>
<td bordercolor="#D9F4B0" bgcolor="#E9F3F3"><div align="center"><span class="style13 style122 style123"><?php echo $name_product;?></span></div></td>
<!--ถ้าเขียนเป็น i แทน row จะใช้ในการนับแบบเรียงลำดับ-->
<td bordercolor="#D9F4B0" bgcolor="#E9F3F3"><div align="center" class="style13 style122 style123"><?php echo $amount;?></div></td>
<td bordercolor="#D9F4B0" bgcolor="#E9F3F3"><div align="center" class="style13 style122 style123"><?php echo $start_date;?></div></td>
<td bordercolor="#D9F4B0" bgcolor="#E9F3F3"><div align="center"><span class="style13 style122 style123"><?php echo $price;?></span></div></td>
<td bordercolor="#D9F4B0" bgcolor="#E9F3F3"><div align="center" class="style13 style122 style123"><a href="del_goatform.php?GoR_ID=<?php echo $row['id_product'];?>"onclick="return confirm('ต้องการลบข้อมูลใช่หรือไม่ !!??');"><img src="../ปุ่ม/c9-d.com_rinoa_icon_set1/close.png" width="24" height="24" border="0" /></a><a href="del_goatform.php?GoR_ID=<?php echo $row['id_product'];?>"onclick="return confirm('คุณต้องการจะลบข้อมูลใช่หรือไม่ !!??');"></a></div></td>
<td bordercolor="#D9F4B0" bgcolor="#E9F3F3"><div align="center" class="style13 style122 style123"></div></td>
</tr>
<?php
//****************************************}
}// end of while
?>
</table>
</body>
</html>
|
|
|
|
|
Date :
2010-03-06 16:27:24 |
By :
clPolLap |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไงก็ลองดูนะคะ สู้ๆ ค่า
|
|
|
|
|
Date :
2010-03-06 16:30:22 |
By :
clPolLap |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|