|
 |
|
ทำระบบ เสิร์ช แล้ว query ไม่ออกค่ะ ช่วยดูให้หน่อยนะคะ ^^ |
|
 |
|
|
 |
 |
|
พอเสิร์ชแล้ว ขึ้น error query ค่ะ ช่วยดูให้หน่อยนะคะ ^^
Code (PHP)
<?
ob_start();
session_start();
if($_SESSION["adminlogin"]=="")
{
header('location:login.php');
exit();
} ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>Administrator</title>
</head>
<? include ("head.php");
echo "<table width=1000 height=50 align=center>
<tr><td width=200 bgcolor=#B9D3EE align=center><a href=adddata_admin.php><h3>Add product's data</h></a></td>
<td width=200 bgcolor=#C1FFC1 align=center><a href=update_admin.php><h3>Edit-Delete product's data</h></a></td>
<td width=200 bgcolor=#B9D3EE align=center><a href=loadad_admin.php><h3>Add product's date</h></a></td>
<td width=200 bgcolor=#C1FFC1 align=center><a href=loadde_admin.php><h3>Delete product's date</h></a></td>
<td width=200 bgcolor=#B9D3EE align=center><a href=logout.php><h3>Log out</h></a></td></tr></table><p><p>";
?>
<form name="frmsearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="100%" border="0" align="right">
<tr>
<th>Select
<select name="ddlselect" id="ddlselect">
<option>- Select -</option>
<option value="nutritionfact.ProductID" <? if($_POST["ddlselect"]=="Product's ID"){echo "selected";}?>/>Product's ID</option>
<option value="date.LotNO" <? if($_POST["ddlselect"]=="Lot Number"){echo "selected";}?>>Lot Number</option>
<option value="nutritionfact.ProductName" <? if($_POST["ddlselect"]=="ชื่อผลิตภัณฑ์") {echo "selected";}?>/>ชื่อผลิตภัณฑ์</option></select>
Keyword <input name="txtkeyword" type="text" id="txtkeyword" value="<?=$_POST["txtkeyword"];?>" />
<input type="submit" value="Search" /></th></tr></table></form>
<?
$objconnect = mysql_connect("localhost","root","password") or die ("Error connect to database");
$objdb = mysql_select_db("nutrition");
// Search by Product's ID or Product's Name or Lot Number
$strsql = "select nutritionfact.ProductID, date.LotNO, nutritionfact.Fig, nutritionfact.ProductName, nutritionfact.Serving_size, nutritionfact.Times, nutritionfact.Energy, nutritionfact.Sugars, nutritionfact.Total_Fat, nutritionfact.Sodium, date.MFG, date.EXP, date.Qrcode from nutritionfact,date where nutritionfact.ProductID = date.ProductID order by ProductID ASC";
if($_POST["ddlselect"] != "" and $_POST["txtkeyword"] != '')
{
$strsql .= " AND (".$_POST["ddlselect"]." LIKE '%".$_POST["txtkeyword"]."%' ) ";
}
$objquery = mysql_query($strsql) or die ("Error Query[".$strsql."]"); ?>
<table border=1> <tr>
<td><center><h4>Product's ID</h></center></td>
<td><center><h4>Lot Number</h></center></td>
<td><center><h4>รูปผลิตภัณฑ์</h></center></td>
<td><center><h4>ชื่อผลิตภัณฑ์</h></center></td>
<td><center><h4>หนึ่งหน่วยบริโภค</h></center></td>
<td><center><h4>ควรแบ่งทาน (ครั้ง)</h></center></td>
<td><center><h4>พลังงาน(กิโลแคลอรี)</h></center></td>
<td><center><h4>น้ำตาล(กรัม)</h></center></td>
<td><center><h4>ไขมัน(กรัม)</h><center></td>
<td><center><h4>โซเดียม(มิลลิกรัม)</h></center></td>
<td><center><h4>วัน เดือน ปีที่ผลิต</h></center></td>
<td><center><h4>วันเดือนปีที่หมดอายุ</h></center></td>
<td><center><h4>รหัสคิวอาร์</h></center></td></tr>
<? while ($dbarr = mysql_fetch_array($objquery))
{
echo "<tr>
<td><center>$dbarr[ProductID]</center></td>
<td><center>$dbarr[LotNO]</center></td>
<td><center><img src='$dbarr[Fig]' height=150></center></td>
<td><center>$dbarr[ProductName]</center></td>
<td><center>$dbarr[Serving_size]</center></td>
<td><center>$dbarr[Times] ครั้ง</center></td>
<td><center>$dbarr[Energy] กิโลแคลอรี</center></td>
<td><center>$dbarr[Sugars] กรัม</center></td>
<td><center>$dbarr[Total_Fat] กรัม</center></td>
<td><center>$dbarr[Sodium] มิลลิกรัม</center></td>
<td><center>$dbarr[MFG]</center></td>
<td><center>$dbarr[EXP]</center></td>
<td><center><img src='$dbarr[Qrcode]'></center></td></tr>";
} echo "</table>";
mysql_close($objconnect); ?>
</body>
</html>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2012-03-13 22:36:13 |
By :
Supergirl |
View :
822 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เจอแล้วค่ะ
ทราบแล้วค่ะว่าผิดตรงไหน ><
|
 |
 |
 |
 |
Date :
2012-03-14 00:33:49 |
By :
Supergirl |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|