Jump to content

Noob needs help for a simple script


MichaelJS

Recommended Posts

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

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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.