Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How to develop a "Previous & Next" Button for Random Content Generator

5:37 pm on Jun 14, 2008 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 25, 2006
votes: 0

Here's the code that I am using successfully to rotate video pages on the home page of my site. I've felt it would be effective to add a "next" and even a "previous" button for users to go through the videos. Here's the code that I have so far - and was wondering how I would continue this. Thanks!

$pages = array(
'videos/1.php', 'videos/2.php');

7:09 pm on June 14, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:Apr 13, 2008
votes: 0

Something like this?

$pages = array(
'videos/1.php', 'videos/2.php', 'videos/3.php');

//If loading for the first time
if( !isset($_GET['load']) ){
$load = 0;

$vid = $load-1;
if($vid < 0) echo "Previous";
else echo "<a href=\"./?load=$vid\">Previous</a>";

$vid = $load+1;
if( $vid > sizeof($pages) ) echo "Next";
else echo "<a href=\"./?load=$vid\">Next</a>";

//Sorry for being a little messy :P
//This way you can load videos directly as well, by links on your site