Forum Moderators: coopster
<?
include("../_includes/mailto.php");
require "config.php"; // All database details will be included here
$page_name="visitor_list.php"; // If you use this code with a different page ( or file ) name then change this
if(!isset($start)) { // This variable is set to zero for the first page
$start = 0;
}
$eu = ($start - 0);
$limit = 5; // No of records to be shown per page.
$this = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
/////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
$order = $_GET['orderby'];
$query2=" SELECT * FROM Visitors order by '$order' ";
$result2=mysql_query($query2);
echo mysql_error();
$nume=mysql_num_rows($result2);
$bgcolor="#f1f1f1";
$query=" SELECT * FROM Visitors order by '$order' limit $eu, $limit ";
$result=mysql_query($query);
echo mysql_error();
<removed a bunch of html - jatar_k>
echo "<table align = 'center' width='50%'><tr><td align='left' width='30%'>";
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
if($back >=0) {
print "<a href='$page_name?orderby=$order&start=$back'><font face='Verdana' size='2'>PREV</font></a>";
}
//////////////// Let us display the page links at center. We will not display the current page as a link ///////////
echo "</td><td align=center width='30%'>";
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit){
if($i <> $eu){
echo " <a href='$page_name?orderby=$order&start=$i'><font face='Verdana' size='2'>$l</font></a> ";
}
else { echo "<font face='Verdana' size='4' color=red>$l</font>";} /// Current page is not displayed as link and given font color red
$l=$l+1;
}
echo "</td><td align='right' width='30%'>";
///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
if($this < $nume) {
print "<a href='$page_name?orderby=$order&start=$next'><font face='Verdana' size='2'>NEXT</font></a>";}
echo "</td></tr></table>";
?>
[edited by: jatar_k at 5:00 pm (utc) on Aug. 26, 2005]