View Full Version : Random PHP file?
DJWilson
02-09-2010, 02:17 PM
Hi,
anyone know or use a script which look's at a list given of PHP file's and then select's one for that page load which would be random on refresh?
Thanks.
Rowleys
02-09-2010, 02:30 PM
I will have a look see what i can do for you ..
DJWilson
02-09-2010, 02:56 PM
Nice one, thank's Dave.
Danno13
02-09-2010, 04:04 PM
Are you giving it the list of files, or does it need to scan from a directory?
If the former, then the quickest way is to use an array, shuffle it and then call the first element -
<?php
$pages = array( "1.php", "2.php", "3.php" );
shuffle($pages);
$page_to_do_something_with = $pages(0);
?>
then do whatever you need to do with the page...
DJWilson
02-09-2010, 04:46 PM
<?php
= array( "1.php", "2.php", "3.php" );
shuffle();
= (0);
?>
This seem's perfect but the file's linked to (I have changed them lol) don't show?
Danno13
02-09-2010, 04:52 PM
Presumably you've added an include line?
include( $page_to_do_something_with);
The code above won't do anything by itself as I didn't know what you wanted to do afterwards..
Marc J
02-09-2010, 05:10 PM
http://www.marcofolio.net/webdesign/php_random_image_rotation.html
Is for images, but can be used for any file type.
DJWilson
02-09-2010, 06:21 PM
Okie, cheer's for you help both of you :)
welby
02-09-2010, 07:58 PM
Okie, cheer's for you help both of you :)
Try this:
http://javascript.internet.com/navigation/random-page.html
DJWilson
02-09-2010, 08:13 PM
Try this:
http://javascript.internet.com/navigation/random-page.html
Thank's, but I only need a section of the site to have the 'random' thing taking place :)
Powered by vBulletin® Version 4.2.0 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.