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 Quote 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. Quote 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? Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.