Welcome to WebmasterWorld Guest from 54.242.94.72

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

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

     

naitsirhc26

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

5+ Year Member



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!

<?php
$pages = array(
'videos/1.php', 'videos/2.php');
shuffle($pages);
include($pages[0]);
?>

ag_47

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

5+ Year Member



Something like this?

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

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

$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
//---AG47
?>

 

Featured Threads

Hot Threads This Week

Hot Threads This Month