Forward/Back button

I’m working on getting a forward/back button working through php for my wiki.

I have a custom pageID for whichever pages that I want the forward and back buttons to work on.

Say the custom pageID is called cID and starts from 1 and goes to 10.

How do I pull from the database what my current page’s cID is? Then to increment, would I just +1 to the cID? If the forward button is pressed, how do I check that there is no next page so that the user isn’t taken to cID 11? IF the cID is 0, how do I do nothing? Would I use an if/else statement where if == 0{/do nothing/}?

Yea, but in reverse. The script should already know that if i’m on page 0, there’s no need to have a link on the previous button (either don’t have it, or make it readonly), and if i’m on page 12 of 12, you can run a check to see if the script needs to disable the next page button.

thank you for your reply :slight_smile:

i understand what i need to do. but how do i do it? i’m at the very beginning stages of teaching myself php

Well, start by posting what you have

I was thinking of doing something along the follow:

[php]<?php
$cur_page = $_REQUEST[‘work_book_page_id’];
$next_page = $cur_page + 1;
if (page_title($next_page) != NULL)
link to URL + “/” + page_title($next_page);
else {}
[/php]

The site im working with at the moment is: www.editions.miltonsociety.org
I’m not sure how to do the if-else statement correctly or if we can even get the page_title in this manner.

I read on other sites about pagination, but I do not want the format of “<<prev 1 2 3 next>>”. I just want to use the buttons I already have on the sides of the menu bar.

Sponsor our Newsletter | Privacy Policy | Terms of Service