MichaelJS Posted September 10, 2007 Share Posted September 10, 2007 Hi all! My programming skills are very limited so i'm here looking for help! I need a simple script that will pick a random image and link from a directory every X seconds. I've done the 1st part, but its updating everytime a user refreshes his browser and i don't want that! I want the script to randomly pick a new picture every hour. This is what i have right now: <?php $fcontents = join ('', file ('banners.txt')); $s_con = split("~",$fcontents); $banner_no = (rand()%(count($s_con)-1)); echo $s_con[$banner_no]; ?> Please give some hints. Thank you Link to comment https://forums.phpfreaks.com/topic/68665-noob-needs-help-for-a-simple-script/ Share on other sites More sharing options...
btherl Posted September 10, 2007 Share Posted September 10, 2007 You'll need to remember the image somehow. Do you want a random image per user per hour? If so, use sessions to remember the image. If you want a random image to be the same for all users for an hour, you will need to store the selected image elsewhere, perhaps in a file or a database. Link to comment https://forums.phpfreaks.com/topic/68665-noob-needs-help-for-a-simple-script/#findComment-345174 Share on other sites More sharing options...
MichaelJS Posted September 10, 2007 Author Share Posted September 10, 2007 You'll need to remember the image somehow. Do you want a random image per user per hour? If so, use sessions to remember the image. If you want a random image to be the same for all users for an hour, you will need to store the selected image elsewhere, perhaps in a file or a database. Yes, all users should see the same picture, and that picture changes randomly every hour, i don't wish to use databases! is there a simple way to do that? Link to comment https://forums.phpfreaks.com/topic/68665-noob-needs-help-for-a-simple-script/#findComment-345175 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.