|
|
|
ติด Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource ช่วยดูหน่อยค่ะ |
|
|
|
|
|
|
|
ช่วยดูให้หน่อยนะคะ ขอบคุณค่ะ
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>
<script>
function setFocus(){
frmsearch.txtkeyword.focus();
}
</script>
<body onLoad="setFocus()">
<? include ("head.php");
echo "<table width=100% 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 bgcolor=#C1FFC1 align=center><a href=updatedata_admin.php><h3>Edit-Delete product's data</h></a></td>
<td bgcolor=#B9D3EE align=center><a href=addnutrient_admin.php><h3>Add nutrient data</h></a></td>
<td bgcolor=#C1FFC1 align=center><a href=adddate_admin.php><h3>Add product's date</h></a></td>
<td bgcolor=#B9D3EE align=center><a href=delete_admin.php><h3>Delete product's date</h></a></td>
</tr><tr>
<td bgcolor=#C1FFC1 align=center><a href=addstandard_admin.php><h3>Add standard</h></a></td>
<td bgcolor=#B9D3EE align=center><a href=updatestandard_admin.php><h3>Edit-Delete standard</h></a></td>
<td bgcolor=#C1FFC1 align=center><a href=addcom_admin.php><h3>Add IP</h></a></td>
<td bgcolor=#B9D3EE align=center><a href=updatecom_admin.php><h3>Update-Delete IP</h></a></td>
<td bgcolor=#C1FFC1 align=center><a href=logout.php><h3>Log out</h></a></td></tr></table><p><p>";
?>
<form name="frmsearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="100%" border="0" align="right">
<tr>
<th>Select
<select name="ddlselect" id="ddlselect">
<option>- Select -</option>
<option value="product.ProductID" <? if($_GET["ddlselect"]=="product.ProductID"){echo"selected";}?>/>Product's ID</option>
<option value="product.ProductName" <? if($_GET["ddlselect"]=="product.ProductName") {echo"selected";}?>/>ชื่อผลิตภัณฑ์</option></select>
Keyword <input name="txtkeyword" type="text" id="txtkeyword" value="<?=$_GET["txtkeyword"];?>" />
<input type="submit" value="Search" /></th></tr></table><br><br></form>
<?
if($_GET["ddlselect"] != "" and $_GET["txtkeyword"] != '')
{
$objconnect = mysql_connect("localhost","root","password") or die ("Error connect to database");
$objdb = mysql_select_db("project");
// Search by Product's ID or Product's Name or Lot Number
$strsql = "select product.ProductID, product.ProductName, product.size, product.Pic, lot.LotNO, Lot.ProductID, lot.MFG, lot.EXP, lot.QrCode from product,lot where product.ProductID = lot.ProductID ";
$strsql .= " AND (".$_GET["ddlselect"]." LIKE '%".$_GET["txtkeyword"]."%')";
$objquery = mysql_query($strsql) or die ("Error Query[".$strsql."]");
$Num_Rows = mysql_num_rows($objquery);
$Per_Page = 2;
$Page = $_GET["Page"];
if(!$_GET["Page"])
{ $Page=1;}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages = 1;}
else if (($Num_Rows % $Per_Page)==0)
{
$Num_Pages = ($Num_Rows/$Per_Page);
}
else
{
$Num_Pages = ($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
$strsql .= " order by ProductID ASC LIMIT $Page_Start , $Per_Page";
$objquery = mysql_query($strsql);
?>
<table border=1> <tr>
<td><center><h4>Product's ID</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><img src='$dbarr[Pic]' height=150></center></td>
<td><center>$dbarr[ProductName]</center></td>
<td><center>$dbarr[MFG]</center></td>
<td><center>$dbarr[EXP]</center></td>
<td><center><img src='$dbarr[Qrcode]'></center></td>
<td><center><a href='sample.php?LotNO=$dbarr[LotNO]'><img src='../nutriproject/sign/preview.png' height='50' border='0' /></a></center></td>
</tr>";
} echo "</table>";?>
<br>
Total <?=$Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{ echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtkeyword=$_GET[txtkeyword]'><< Back</a>";
}
for($i=1; $i<=$Num_Pages; $i++)
{
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtkeyword=$_GET[txtkeyword]'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page != $Num_Pages)
{
echo " <a href = '$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtkeyword=$_GET[txtkeyword]'>Next>>/a>";
}
mysql_close($objconnect);
}
?>
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2012-04-08 22:22:17 |
By :
Supergirl |
View :
1228 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$objquery = mysql_query($strsql) or die(mysql_error());
|
|
|
|
|
Date :
2012-04-09 06:30:32 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โอ๊ะ!!! จริงด้วย ขอบคุณค่ะ
|
|
|
|
|
Date :
2012-04-09 16:31:38 |
By :
Supergirl |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|