Jump to content

modifying pagination issue


$php_mysql$

Recommended Posts

friends currently my pagination shows like

 

pages count

 

Page 2 of 11

 

clickable link

Prev»  Next»

 

how can i achieve to get the countable page numbers to show like clickable and then 1, 2, 3 , 4  etc no matter how many there are.

 

here are the codes

 

$p = 1;
if ($nxpage == "")$nxpage = "1";
$countfile= count($items);
$countfile=$countfile-2;
$first=($nxpage*$p)-$p;
$nxpages = ceil($countfile / $p);

$next_arrays=($first+($p-1));






if ($nxpage <= $nxpages and $nxpage>1) $gline_rew1 = '<a 
href="'.$_SERVER["PHP_SELF"].'?nxpage='.($nxpage-1).'">Prev&#187;</a> ';
if ($nxpages > 1 and $nxpage<$nxpages) $gline_next1 = ' <a 
href="'.$_SERVER["PHP_SELF"].'?nxpage='.($nxpage+1).'">Next&#187;</a>';
echo "Page {$nxpage} of {$nxpages} <br/> ".$gline_rew1.$gline_next1."";

Link to comment
https://forums.phpfreaks.com/topic/240951-modifying-pagination-issue/
Share on other sites

The variable $nxpages contains the numbers of pages you have. To display a link for each page you'd use for loop.

 

Something like this should work

for($i = 1; $i <= $nxpages; $i++)
    echo ' <a href="'.$_SERVER["PHP_SELF"].'?nxpage='.$i'">'.$i.'</a> ';

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.