|
|
|
ทำการค้นหาโดยใช้วันที่ในการค้นหา แล้วมี การแบ่งหน้าให้กับผลลัพที่ค้นหา |
|
|
|
|
|
|
|
เขียนให้ดูครับ
Code (PHP)
<form id="form1" name="form1" method="post" action="withdrawldate.php">
<table width="229" border="0">
<tr>
<td width="76">วันที่</td>
<td width="87"><label for="datepicker-en"></label>
<input name="date" type="text" id="date" size="10"/></td>
<td width="114"><input type="submit" name="Submit" value="ค้นหา" /></td>
</tr>
</table>
</form>
<?
$date=$_POST['date'];
if($date=="")
{
$date=$_GET['date'];
}
$objConnect = mysql_connect("localhost","root","12345") or die("Error Connect to Database");
$objDB = mysql_select_db("project");
$strSQL = "select*
from mixall,product_group,product,mixpack,bag,box
where mixall.pg_id = product_group.pg_id
and product_group.pro_id = product.pro_id
and mixall.p_id=mixpack.p_id
and mixpack.bg_id = bag.bg_id
and mixpack.bx_id = box.bx_id
and mixall.date_time ='$date'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 5; // Per Page
$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 mix_id ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="673" border="1" cellspacing="0" bordercolor="#333333">
<tr>
<td colspan="8" align="center">รายการผลิตภัณฑ์ที่ทำการผสมวันนี้</td>
</tr>
<tr>
<td width="41" align="center" bgcolor="#FFFF66">ลำดับ</td>
<td width="74" align="center" bgcolor="#FFFF66">รหัสผสม</td>
<td width="231" align="center" bgcolor="#FFFF66">ผลิตภัณฑ์</td>
<td width="141" align="center" bgcolor="#FFFF66">วันที่</td>
<td width="68" align="center" bgcolor="#FFFF66">สถานะเบิก</td>
</tr>
<? $c=1;
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td align="left"><? echo $c;?></td>
<td align="left"><?=$objResult["mix_id"];?></td>
<td align="left"><?=$objResult["mix_id"];?></td>
<td align="center"><?=dateThai($objResult['date_time']);?></td>
<td align="center"> </td>
</tr>
<? $c=$c+1; } ?>
</table>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&date=$date'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&date=$date'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&date=$date'>Next>></a> ";
}
mysql_close($objConnect);
?>
|
|
|
|
|
Date :
2012-05-30 11:28:26 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|