Hi,
I know this has perhaps been covered here, but I can't find anything that helps me.
I am trying to display navigation links at the bottom of a page, hoping to show them in groups of 10, displaying 15 records per page, but with the first and last pages showing as links as well, so the user doesn't have to cycle through "next and next" to get to the last page.
Is there a fairly easy way to do this?
I am using a MySQL db.
This is the code I have now:
$per_page = 15; // Number of items to show per page
$showeachside = 10; // Number of items to show either side of selected page
if(empty($start)){
$start=0; // Current start position
}
$max_pages = ceil($num_resumes/$per_page); // Number of pages
$cur = ceil($start / $per_page)+1; // Current page number
$i=$start;
while ($i<min($num_resumes,($start+$per_page))) {
$resume_id=mysql_result($result,$i,"resume_id");
$contactid=mysql_result($result,$i,"contact_id");
etc....
writes out html...
}
<table border="0" width="85%" cellpadding="0" cellspacing="0">
<tr>
<td width="30%">
<? if(($start-$per_page) >= 0)
{
$next = $start-$per_page; ?>
<p align="right"><b><a href="<? echo("viewapplicants.php?vids=$view_cont".($next>0?("&start=").$next:""));?>"><<</a></b>
<? } ?></td>
<td width="40%"><p align="center">Page <? print($cur);?> of <? print($max_pages);?>
( <? print($num_resumes);?> records )<br />
<? $eitherside = ($showeachside * $per_page);
if($start+1 > $eitherside)print (" .... ");
$pg=1;
for($y=0;$y<$num_resumes;$y+=$per_page)
{
$class=($y==$start)?"pageselected":"";
if(($y > ($start - $eitherside)) && ($y < ($start + $eitherside)))
{
?>
<a href="<? echo "viewapplicants.php?vids=$view_cont&start=$y";?>"><b><? echo($pg);?></b></a>
<? }
$pg++;
}
if(($start+$eitherside)<$num_resumes)print (" .... ");
?>
</td>
<td width="30%">
<?
if($start+$per_page<$num_resumes)
{ ?>
<a href="<? echo("viewapplicants.php?vids=$view_cont&start=".max(0,$start+$per_page));?>"><b>>></b></a>
<? } ?>
Thanks,
Paul