$php_mysql$ Posted July 2, 2011 Share Posted July 2, 2011 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»</a> '; if ($nxpages > 1 and $nxpage<$nxpages) $gline_next1 = ' <a href="'.$_SERVER["PHP_SELF"].'?nxpage='.($nxpage+1).'">Next»</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 More sharing options...
wildteen88 Posted July 2, 2011 Share Posted July 2, 2011 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> '; Link to comment https://forums.phpfreaks.com/topic/240951-modifying-pagination-issue/#findComment-1237634 Share on other sites More sharing options...
$php_mysql$ Posted July 2, 2011 Author Share Posted July 2, 2011 getting an error using that Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' Link to comment https://forums.phpfreaks.com/topic/240951-modifying-pagination-issue/#findComment-1237639 Share on other sites More sharing options...
EdwinPaul Posted July 2, 2011 Share Posted July 2, 2011 Should be: for($i = 1; $i <= $nxpages; $i++) echo ' <a href="'.$_SERVER["PHP_SELF"].'?nxpage='.$i.'">'.$i.'</a> '; Link to comment https://forums.phpfreaks.com/topic/240951-modifying-pagination-issue/#findComment-1237646 Share on other sites More sharing options...
$php_mysql$ Posted July 2, 2011 Author Share Posted July 2, 2011 Should be: for($i = 1; $i <= $nxpages; $i++) echo ' <a href="'.$_SERVER["PHP_SELF"].'?nxpage='.$i.'">'.$i.'</a> '; hey bro above codes and yours looks similar but how come urs worked? Link to comment https://forums.phpfreaks.com/topic/240951-modifying-pagination-issue/#findComment-1237755 Share on other sites More sharing options...
wildteen88 Posted July 2, 2011 Share Posted July 2, 2011 I didn't concatenate my variables correctly. This is what $php_mysql$ fixed. Below highlights the missing character from my code (the red dot) echo ' <a href="'.$_SERVER["PHP_SELF"].'?nxpage='.$i.'">'.$i.'</a> '; Link to comment https://forums.phpfreaks.com/topic/240951-modifying-pagination-issue/#findComment-1237762 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.