What is wrong with my code? It makes the links and all right, but it puts all of the returned records in the first page, and leaves nothing for the second page. But, it does recognize that it needs two pages for that amount of records.
<?
if ($num_p <= $limit)
{
/*
Added this statement so if the result shows less that or the
equal ammount of the limit to show nothing at all , to kill
the "1" that was just generated
*/
}
else
{
// Don't display PREV link if on first page
if ($offset!=0)
{
$prevoffset=$offset-$limit;
echo "<a onMouseOver=\"window.status='Previous $limit Results';
return true\";
href=\"$PHP_SELF?offset=$prevoffset&index=$prevoffset&keyword=$encode1&companyt=$encode2\"><B>[Previous]</B></a>   ";
}
/*
I particularly like having the [Previous] on the first page
if it has enough results to display at all with my mod , just helps
set the over all structure of the navigation system its self
so ill just add this to the above if statement
*/
else echo "<b><font color=#666666>[Previous]</font></b>   ";
/*
If its not to your likeing simply comment it out ;)
*/
// Calculate total number of pages in result
$pages = intval($num_p/$limit);
// $pages now contains total number of pages needed unless there is a remainder from division
if ($num_p%$limit)
{
// has remainder so add one page
$pages++;
}
// Now loop through the pages to create numbered links
// ex. 1 2 3 4 5 NEXT
for ($i=1;$i<=$pages;$i++)
{
// Check if on current page
if (($offset/$limit) == ($i-1))
{
// $i is equal to current page, so don't display a link
echo " <b><font color=#666666>$i</font></b> ";
}
else
{
// $i is NOT the current page, so display a link to page $i
$newoffset=$limit*($i-1);
echo " <a onMouseOver=\"window.status='Page $i Results';
return true\";
href=\"$PHP_SELF?offset=$newoffset&index=$newoffset\"><B>$i</B></a> \n";
}
}
// Check to see if current page is last page
if (!((($offset/$limit)+1)==$pages) && $pages!=1)
{
// Not on the last page yet, so display a NEXT Link
$newoffset=$offset+$limit;
echo "    <a onMouseOver=\"window.status='Next $limit
Results'; return true\";
href=\"$PHP_SELF?offset=$newoffset&index=$newoffset\"><B>[Next]</B></a><p>\n";
}
/*
Im doing the same thing here as i did in the [Previous] above
*/
else echo "   <b><font color=666666>[Next]</font></b>";
}
?>