Jess McKenzie Jess McKenzie - 1 year ago 74
PHP Question

onClick show the next page

I am creating a page pagination however I am stuck on the for loop. Currently it shows all links from 1 to 99.

How can I make it so that it only shows one number per click as I am wanting to create a "next" button.

Do I have to involve jQuery?



for ($i = 1; $i <= 99; ++$i) {

echo '<li><a href="example-' .$i. '">Next</a></li>';


Answer Source

looks like you jut need this:

if($_GET['page'] >=99){
 exit('ran out of pages');
//no idea what you want here :-)

if(empty($_GET['page']) OR !is_int($_GET['page'])){
$_GET['page']=0; //or maybe you want 1, depends on usage

echo '<li><a href="example.php?page=' .$next. '">Next</a></li>';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download