You know what.. that might just work the way I need it to... will try it out
tonight, thanks!!! :)

Brad C.

-----Original Message-----
From: Hugh Bothwell [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 03, 2001 1:05 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Pulling a random image



"Brad R. C." <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> But what my goal was is to make it where it goes through all the images
> before showing a random twice.

... if you actually want to do this, you will have to keep track
of which items you have seen in the last rotation.


> Now... I thought the following function did that, but for some reason it
is
> not...

Nope.  You are just (inefficiently) choosing one item at random.

An equivalent-but-faster approach would be
    SELECT * FROM user
    WHERE valid=1 AND inrotation=1
    ORDER BY RAND() LIMIT 1


If you really need random-order, once-per-cycle images,
you could achieve it by adding a 'views' field to the table;
initialize all entries to the same value (ie 0).  Each time an image
is displayed, increment the views; when you choose an image,
choose from the pool where the views value is minimal, ie.

SELECT id,imgname FROM user
WHERE valid=1 AND inrotation=1 AND views=MIN(views)
ORDER BY RAND() LIMIT 1

UPDATE user SET views=views+1
WHERE id=$id

How's that?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to