<?
require_once "pagecreator.php";
$db_HOST="localhost";
$db_USER="root";
$db_PASS="PASSWORD";
$db_NAME="MYSQLDATABASE"; //NAME OF THE DATABASE WHERE THE EXAMPLE TABLE CAN BE FOUND
$dbh=mysql_connect ($db_HOST,$db_USER,$db_PASS)
or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ($db_NAME,$dbh);
// Make query
if (!$st) $st=0;
$st=(int) $st;
if (!$rows) $rows=10;
$rows=(int) $rows;
if ($rows<1) $rows=10;
$query_db="select * from categories order by cat_id limit $st,$rows";
$query_total_cats="select * from categories ";
$result=mysql_query($query_db);
$total_cats=mysql_num_rows(mysql_query($query_total_cats));
//make pagelinks with pagecreatorclass
$pg=new page_creator();
$pg->TotalItems=$total_cats;
$pg->ItemsPerPage=$rows;
$pg->PrevNext=true;
$pg->FirstLast=true;
$pg->TrailingPages=2;
$pg->ShowTotalPages=true;
$pg->ShowTotalPagesString="Total of pages: ";
$pg->ScriptVariable="st";
$pg->Parameters=array('amount'=>$rows);
$nav=$pg->Create_Pagelinks();
print $nav."<br />";
// display the contents of the page
print '<table width="60%" border="1px">';
while ($r=mysql_fetch_array($result)) {
print '<tr><td>' . $r['cat_id'] . '</td>';
print '<td>' . $r['cat_1'] . '</td>';
print '<td>' . $r['cat_2'] . '</td></tr>';
}
print '</table>';
//
?>
|