Forum Moderators: coopster
I've got a totally random image rotator script - reloads a different random image on every re-load - but I'd prefer a script that would load images in a sequential order vs. totally random.
So the first time you load the page, you get Image One.
If you hit refresh, you get Image Two. And so on, around to One again.
It doesn't need to be fancy - I don't want to setup a database just to do this one little thing, and
I don't need it to leave cookies or anything saying that you've been there and you need the next image!
I just have two sites where I know the people in the pics are going to want to see themselves, so I'd like them to be able to reload the page until it hits to their pic. :-) It won't be as random, but hey.
If there was a script that randomized until it "ticked off" every pic in a list, even better... but not 100% necessary.
Let me know what you think - I swear I've seen the above before, but over two hours of searching and I can't find anything... lots of totally random scripts.
Since you don't want cookies take a look at session handling functions [ca2.php.net], how you impliment it is up to you. ;)
Personally I'd do a server-side counter, just rotate that every time, and send the next image to the user when they first connect, every time a page is requested, regardless of any sessions keep rotating that number. Then when someone connects, use a session to keep track of a temporary number which is the image they get, start with the main number (so chances are they get a different one if they wait more than 15 minutes, or however long your sessions last for), but it also keeps things a little more interesting for the random viewer.
I'd also do the image as a single image.php script, so the main page(s) had nothing to do with the image rotation itself, just set the Content-type: header before returning anything. The downside of this is that some browsers ignore type and go via filename (that's their problem, it's against the rules anyway ;-)
Even from a beginner php point of view, it should be pretty simple to put together something, even cutting and pasting from various counter scripts...