|
 |
|
ช่วยแบ่งหน้าหน่อยครับ แสดงผลเป็นหน้า ขอบพระคุณล่วงหน้านะครับ ขอบคุณครับผม |
|
 |
|
|
 |
 |
|
f(!isset($start)){
$start= 0;
}
$limit = '10';
//------------ query ข้อมูลค่ะ หาจำนวนแถวทั้งหมด
$sql = "select Train_Id,Origin_Station,Destination_Station,Dep_Time,Arr_Time from traintime_tablego";
$result=mysql_db_query($dbname,$sql);
$numrow=mysql_num_rows($result);
//-----------query ข้อมูลเพื่อแสดงผลเป็นหน้าๆ
$psql = "select Train_Id,Origin_Station,Destination_Station,Dep_Time,Arr_Time from traintime_tablego limit $start,$limit";
$resultp=mysql_db_query($dbname,$psql);
$record=mysql_fetch_array($resultp);
while ($record=mysql_fetch_array($resultp)) {
//-- วนลูปแสดงข้อมูล ...
...
---<td></td>
}
<tr>
<td>
//-------------- ตรงนี้จะแสดงการแบ่งหน้าค่ะ อยู่ในเทเบิลแถวสุดท้ายซึ่งไม่ได้วนลูปตามไปด้วย
<?
$page= ceil($numrow/$limit); // เอา record ทั้งหมด หารด้วย จำนวนที่จะแสดงของแต่ละหน้า
echo "จำนวนทั้งหมด ".($page)." หน้า ----- ";
if(!isset($thispage)){ $thispage=1; }
$prev=$thispage-1;
$next=$thispage+1;
if($prev!=0)
{
echo"<a href='?start=0&page=1'> << </a>";
echo" | <a href='?start=".$limit*($thispage-2)."&thispage=".($thispage-1)."'>[ ก่อนหน้า]</a> | ";}
else{}
echo"หน้า ";
echo $thispage;
if($next <= $page)
{ echo" | <a href='?start=".$limit*($thispage)."&thispage=".($thispage+1)."'> [ถัดไป]</a> |";
echo"<a href='?start=".$limit*($page-1)."&thispage=".($pageschool)."'> >> </a>";
}
?>
</td>
</tr>
เอาไปปรับใช้เอาเน้อ
|
 |
 |
 |
 |
Date :
22 ม.ค. 2551 15:24:33 |
By :
hobbits |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|