<?
// see online: http://kentung.f2o.org/scripts/paging/sample4.php
require("paging_class.php");
// create table //
$td=3;
$tr=4;
$paging=new paging(($td*$tr),5);
$paging->db("localhost","username","password","dbname");
$paging->query("select * from paging order by MY_FIELD asc");
$page=$paging->print_info();
echo "Data $page[start] - $page[end] of $page[total] [Total $page[total_pages] Pages]<hr>\n";
$table_tr=ceil(($page[total]-$page[start]+1)/$td);
if ($table_tr>$td) $table_tr=$tr;
$table_td=($page[total]-$page[start])+1;
if ($table_td>$td) $table_td=$td;
echo "<table border=\"1\">";
for ($i=1;$i<=$table_tr;$i++) {
echo "<tr>";
for ($j=1;$j<=$table_td;$j++) {
$result=$paging->result_assoc();
$color=$paging->print_color("yellow","#FFCCCC");
$number=$paging->print_no();
if ($number>$page[total]) {$number=" ";}
echo "<td bgcolor=\"$color\">$number $result[MY_FIELD]</td>";
}
echo "</tr>\n";
}
echo "</table>";
echo "<hr>".$paging->print_link();
?>
|