Gah can't figure out really simple MySQL!

Associate
Joined
16 May 2005
Posts
680
Two columns, one has an image name the second image category. Basically I want to select an image from each category (there's 4 categories) so I need something along the lines of

Code:
"SELECT flash_box_category_id, flash_box_image FROM flash_box GROUP BY flash_box_category_id ORDER BY RAND() LIMIT 4";

Now this pulls out 4 different category images, but it's the same 4 each time, the rand isn't used?
 
Don't you have to "seed" the RAND to get it to start at a different point - don't know how - just remember reading this somewhere?

"Seed: A integer used to set the starting point for generating a series of random numbers. The seed sets the generator to a random starting point. A unique seed returns a unique random number sequence."

Use - mt_srand() or srand()
 
Last edited:
Back
Top Bottom