Web Hosting Talk







View Full Version : Does anyone know this script or code???


l45tor
01-05-2003, 06:23 PM
Does anyone know the code or script for writng like 3 stories and then the script will change and show one of the stories every time the site is visited??

For example if u go to the site it will show STORY "KIDS" then reload it and a different story will be on like titled "Cars"

Like the story is constantly changing???

any help will be greatly appreciated thanks
Lee Ruiz

xerocity.com
01-05-2003, 06:35 PM
I do not know of anything in particular but if you need one and can't find it online let me know.

gambitdis
01-07-2003, 11:05 PM
I'm writing this code off the top of my head, so it may or may not work :) The ideas *should* be correct though.

<?php
srand((double)microtime()*1000000);
$randomval = rand(1,2);
?>

if you have 5 stories, change rand(1,2) to rand(1,5)

Then name your include documents doc_1.txt, doc_2.txt, etc.

read the file:
<?php
$filename = "doc_" . $randomval . ".txt";
include($filename);
?>

That should do it.

nameslave
01-08-2003, 02:13 PM
http://www.cgi-resources.com/Programs_and_Scripts/Perl/Random_Items/Random_Text/