
March 12th, 2005, 07:57 AM
|
|
Registered User
|
|
Join Date: Mar 2005
Posts: 2
Time spent in forums: 22 m 5 sec
Reputation Power: 0
|
|
|
paging problem
Hey Guys,
I am using the following class for paging my results:
PHP Code:
function page_break($numrows, $offset, $limit) { $multi = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"border-collapse: collapse\" bordercolor=\"#111111\" width=\"80%\" id=\"AutoNumber14\"><tr>"; $pages=intval($numrows/$limit); $extra = $_SERVER["QUERY_STRING"]; $extra = explode("&", $extra); for($i = 0; $i < count($extra); $i++) { if($extra[$i]) { if(!strstr($extra[$i],"offset=")) { $current .= $extra[$i]. "&"; } } } if ($numrows%$limit) { $pages++; } $do = $offset+2; $increase1 = 1; $increase2 = $limit; if ($do > $numrows) { $increase1 = 1; $increase2 = 1; } if ($offset >= 1) { $prevoffset = $offset - $limit; $prev .= "<td width=\"12%\"><a href=\"$PHP_SELF?$current\"><img border=\"0\" src=\"images/01.gif\" width=\"22\" height=\"24\"></a></td> <td width=\"12%\"><a href=\"$PHP_SELF?$current&offset=$prevoffset\"><img border=\"0\" src=\"images/01a.gif\" width=\"22\" height=\"24\"></a></td>\n"; } if (! ( ($offset/$limit) == ($pages - 1) ) && ($pages > 1) ) { $newoffset = $offset+$limit; $next .= "<td width=\"12%\"><a href=\"$PHP_SELF?$current&offset=$newoffset\"><img border=\"0\" src=\"images/02a.gif\" width=\"22\" height=\"24\"></a>"; $not_last = 1; } $multi .= $prev; $multi .= "<td width=\"60%\" class=\"sml\"><p align=\"center\"><b><font color=\"#FF6600\">"; for ($i = 1; $i <= $pages; $i++) { $newoffset = $limit*($i-1); if ($newoffset == $offset) { $multi .= "[$i] \n"; } else { $multi .= "<a href=\"$PHP_SELF?$current&offset=$newoffset\">$i</a> \n"; } } $multi .= "</td>"; $multi .= $next; $multi .= "<td width=\"15%\"><a href=\"$PHP_SELF?$current&offset=$newoffset\"><img border=\"0\" src=\"images/02.gif\" width=\"22\" height=\"24\"></a></td>"; $multi .= "</tr></table>"; return $multi; }
Now, the above works fine. However, the problem is, there are times when there are more than 1,000 results. This causes over 100 page links to be created. How do i limit only 10 pages to be listed at a time?
Something like this:
<< < 4 5 6 7 8 9 10 11 12 13 14 > >>
Thank you
unregistered.
|