คือมันแบ่งหน้าได้นะคับ แต่เวลาคลิ๊กลิ้งเปลี่ยนหน้าแล้วมันไม่เจอผลลัพธ์
โค้ด:
$strSQL ="select * from data where date >= '$year-$month-$day' and date <= '$year2-$month2-$day2'";
$objQuery =mysql_query($strSQL,$Conn) or die ("ไม่สามารถเรียกดูข้อมูลในเทเบิล ได้");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 10; // 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 date ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
echo "<P><B>ข้อมูล</B></P>
<table border='1'>
<tr BGCOLOR='#E8E8E8'>
<td><center><b>เลขที่</b></center></td>
<td><center><b>วันที่</b></center></td>
<td><center><b>บัญชี</b></center></td>
<td><center><b>จำนวนเงิน</b></center></td>
<td><center><b>[แก้ไข]</b></center></td>
<td><center><b>[ลบ]</b></center></td>
<td><center><b>[รายละเอียด]</b></center></td>
</tr>";
while($row=mysql_fetch_array($objQuery)){
$iddata=$row[iddata];
$date=$row[date];
$money=$row[money];
$idaccount=$row[idaccount];
$sql2="select account from account where idaccount='$idaccount'";
$table2=mysql_query($sql2,$Conn) or die ("ไม่สามารถเรียกดูข้อมูลในเทเบิลได้");
$row2=mysql_fetch_array($table2);
$account=$row2[account];
echo "
<tr>
<td>$iddata</td>
<td>$date</td>
<td>$account</td>
<td>$money</td>
<td><a href=\"edit_budget.php?id_edit=$iddata\">[แก้ไข]</a></td>
<td><a href=\"delete_budget.php?id_del=$iddata\"onclick=\"return confirm('ยืนยันการลบเลขที่ใบสำคัญ $iddata ออกจากระบบ')\">[ลบ]</a></td>
<td><a href=\"view_budget.php?id_view=$iddata\">[รายระเอียด]</a></td>
</tr>";
}
echo "</table>";
?>
<br>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}