if($chapter!=0){ // if chapter has some value and if its not 0.
$prev_link=$chapter - 1; //set previous link as chapter - 1.
} else {
$prev_link=0; //if chapter = 0, then theres no previous link, make it 0 as well.
}
if($chapter < count($lines)){ //if the chapter is less than the number of lines, next_link is valid.
$next_link=$chapter + 1; //assign next chapter to $next_link
}
echo "<a href='file.php?chapter=$prev_link'>Previous chapter</a>";
echo "<a href='file.php?chapter=$next_link'>Next chapter</a> Thats it, i guess. Btw, most of the people dont use vars anymore. Its outdated. You can do something like this.
[inline]
$file_select=(isset($_REQUEST['file_select']))?$_REQUEST['file_select']: "ttc_intro";[/inline] Here you are checking if file_select has been set by any of the methods, $_GET or $_POST. if its set, then assign that value to $file_select, else, assign ttc_intro to $file_select. You can do the same thing while checking for chapters as well..
Cheers,
Naveen
nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356