Jump to content

php help :D


ctcp

Recommended Posts

<?php
if ($page != 0) { 
$back_page = $page - $limit;
echo("<a href=\"$PHP_SELF?section=first&query=$query&page=$back_page&limit=$limit\">Back</a>    \n");}

for ($i=1; $i <= $pages; $i++) 
{
$ppage = $limit*($i - 1);
if ($ppage == $page){
echo("<b>$i</b> \n");} 
else{
echo("<a href=\"$PHP_SELF?section=first&query=$query&page=$ppage&limit=$limit\">$i</a> \n");}
}

if (!((($page+$limit) / $limit) >= $pages) && $pages != 1) { 
$next_page = $page + $limit;
echo("    <a href=\"$PHP_SELF?section=first&query=$query&page=$next_page&limit=$limit\">Next</a>\n");}
?>

 

i got this result page

results is 50 per page

i got now

Back 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Next

 

how to view only 10 links .. i mean like this

Back 1 2 3 4 5 6 7 8 9 10 Next

Back 5 6 7 8 9 10 11 12 13 14 15 Next

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/163980-php-help-d/
Share on other sites

<?php
$p = $page/$limit+1;
$start = max(1,min($p-5, $pages-10));
$end = min($pages, max($p+5, 11));

for ($i=$start; $i <= $end; $i++) 
{
$ppage = $limit*($i - 1);
if ($ppage == $page){
echo("<b>$i</b> \n");} 
else{
echo("<a href=\"$PHP_SELF?section=first&query=$query&page=$ppage&limit=$limit\">$i</a> \n");}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/163980-php-help-d/#findComment-865089
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.