homepage Welcome to WebmasterWorld Guest from 54.242.140.11
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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

5+ Year Member



 
Msg#: 3674839 posted 5:37 pm on Jun 14, 2008 (gmt 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!

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

 

ag_47

5+ Year Member



 
Msg#: 3674839 posted 7:09 pm on Jun 14, 2008 (gmt 0)

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
?>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved