|
 |
|
โค๊ดแบ่งหน้า มาใช้กับ ADODB แล้วไม่ยอมตัด Row แบ่งหน้า ให้อ่าครับ ดูให้ทีครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<?php
include "config.inc.php";
include "adodb5/adodb.inc.php";
$conn=NewADOConnection('mysql');
$conn->Connect($db_host,$db_user,$db_pass,$db_name);
$conn->Execute($db);
$sql = "select * from namesent";
$result = $conn->Execute($sql);
echo "<table border='1' >";
echo "<tr>";
echo "<td align='center' width='300' align='center'font color='993300'><h6>หัวข้อ</h6></td>";
echo "<td align='center' width='300' align='center' font color='993300'><h6>รายละเอียด</h6></td>";
echo "<td align='center' width='300' align='center' font color='993300'><h6>กำหนดส่ง</h6></td>";
echo "</tr>";
$Num_Rows = $result->RecordCount();
$Per_Page = 2; // 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;
}
//$sql.=" order by namesent DESC LIMIT $Page_Start , $Per_Page";
while (!$result->EOF)
{
echo "<td align='center' width='400' >".$result->fields['name_th']."</td>";
echo "<td align='center' width='400' >".$result->fields['detail']."</td>";
echo "<td align='center' width='400' >".$result->fields['time_send']."</td>";?>
<?php $result->MoveNext();
echo "</tr>";
}
echo "</table>";
print "<font color='#0099FF'><br>หน้าทั้งหมด = $Num_Pages หน้าปัจจุบัน =</font>";
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><font color='#0099FF'><< Back</font></a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'><font color='#0099FF'>$i</font></a> ]";
}
else
{
echo "<b><font color='#0099FF'> $i </font></b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'><font color='#0099FF'>Next>></font></a> ";
}
?>
|
 |
 |
 |
 |
Date :
2012-03-23 22:50:51 |
By :
mix |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2012-03-23 22:52:39 |
By :
mix |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|