pagination works well, it even displays the rows i wanted, however, my problem now is that i cannot access or it does not display the next rows from my database, i think there is some problem with regards to my next/previous/last/first links,,
please help me asap, tnx!
$result = mysql_query("SELECT * FROM sec_ph ORDER BY phStatus") or die(mysql_error());
echo "<center>";
//This checks to see if there is a page number. If not, it will set it to page 1
if (!(isset($pagenum)))
{
$pagenum = 1;
}
$rows = mysql_num_rows($result); //Here we count the number of results
$page_rows = 4; //This is the number of results displayed per page
$last = ceil($rows/$page_rows); //This tells us the page number of our last page
if ($pagenum < 1) //this makes sure the page number isn't below one, or more than our maximum pages
{
$pagenum = 1;
}
elseif ($pagenum > $last)
{
$pagenum = $last;
}
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This sets the range to display in our query
$result2 = mysql_query("SELECT * FROM sec_ph ORDER BY phStatus $max") or die(mysql_error());
$resultCount = mysql_query("SELECT COUNT(*) FROM sec_ph") or die(mysql_error());
$count = mysql_result($resultCount,0,0);
echo "<b></center>Record Count: </b> $count record(s)<br><br><center>";
echo "<table border = 1 bordercolor='#996633' cellpadding = 4><tr bgcolor = #FFFFCC><th><font size = 2>Type</th><th><font size = 2>Customer</th></tr>";
while($row = mysql_fetch_array($result2))
{
echo "<tr><td><font size = 2>";
echo $row['phType'];
echo "</td><td><font size = 2>";
echo $row['phCustomer'];
echo "</td></tr>";
}
echo "</table>";
echo "<br><br><center>Page $pagenum of $last<br><br>"; // This shows the user what page they are on, and the total number of pages
// First we check if we are on page one.
//If we are then we don't need a link to the previous page or the first page so we do nothing.
//If we aren't then we generate links to the first page, and to the previous page.
if ($pagenum == 1)
{
}
else
{
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'>First</a> ";
echo " ";
$previous = $pagenum-1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'>Previous</a> ";
}
//This does the same as above, only checking if we are on the last page, and then generating the Next and Last links
if ($pagenum == $last)
{
}
else
{
$next = $pagenum+1;
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next</a> ";
echo " ";
echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last</a> ";
}