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
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.

Link to comment
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.

 

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.