How to pass $_GET in pagination in php -
this code works if running pagination, when there $_get
variable passed shows first page , when clicked on next loads data in db , runs beginning.
i know how can pass $_get
variable passed.
<?php if ($currentpagerec > 1) { echo " <a href='{$_server['php_self']}?currentpagerec=1'>first page</a> "; prevpagerec = $currentpagerec - 1; echo " <a href='{$_server['php_self']}?currentpagerec=$prevpagerec'>previous page</a> "; } ($x = ($currentpagerec - $rangerec); $x < (($currentpagerec + $rangerec) + 1); $x++) { if (($x > 0) && ($x <= $totalpagesrec)) { if ($x == $currentpagerec) { echo " [<b>$x</b>] "; } else { echo " <a href='{$_server['php_self']}?currentpagerec=$x'>$x</a> "; } } } if ($currentpagerec != $totalpagesrec) { $nextpagerec = $currentpagerec + 1; echo " <a href='{$_server['php_self']}?currentpagerec=$nextpagerec'>next page</a> "; echo " <a href='{$_server['php_self']}?currentpagerec=$totalpagesrec'>last page</a> "; } ?>
based on code, wondering whether should register global variables http://php.net/manual/en/security.globals.php
your code use variables globals, whereas in fact should refer variables, e.g.
<?php if ($_get['currentpagerec'] > 1) { //[etc] ?>
further comment below: tried say: user $_get (etcetera), code appears based on (depreciated) global variabels.
--- edit ---
further updated shared code: have pass each variable again when using pagination, e.g. last line
<? // code define $totalpagesrec // code define $keyword // personal preference split echo between static texts , variables echo " <a href='".$_server['php_self']."?currentpagerec=".$totalpagesrec."&keyword=".$keyword."'>last page</a> "; ?>
hope helps
Comments
Post a Comment