Forum Moderators: coopster

Message Too Old, No Replies

Image rotation (a new image on page load) in sequence, not random

...and from a flat file, not db. Anyone know of a good script?

         

Undead Hunter

6:23 pm on Jul 31, 2003 (gmt 0)

10+ Year Member



Hi Gang:

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.

jatar_k

7:29 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The only options I can think of are cookies or sessions. You need something that identifies that particular user and can get data from a page that has gone by.

Since you don't want cookies take a look at session handling functions [ca2.php.net], how you impliment it is up to you. ;)

vincevincevince

9:06 pm on Jul 31, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



...however cookies are the way to go

RobinC

9:24 pm on Jul 31, 2003 (gmt 0)

10+ Year Member



No cookies huh, and sessions are limited in duration...

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

Undead Hunter

8:05 pm on Aug 1, 2003 (gmt 0)

10+ Year Member



Thanks for the thoughts, folks.

I've found a script for $14 that handles both random and sequence image loading - guess that's going to be the winner (and I guess it can be done - although I don't yet know if its session or cookie based or...? )

Once again, I appreciate your input!