Brain Fart.
June 8th, 2006Considering I struggled for about a day to think of the easiest way to do this I feel completely stupid that I forgot how to randomize a set of mysql results in PHP. Especially after remembering the secret to it all. Simply adding ‘ORDER BY RAND()’ to your SQL statment.
The source of confusion is in the fact that once you have a set of rows from MySQL in PHP you cannot randomize them. The calls are retrieved individually through a ‘mysql_fetch_array’ or similar call and there isn’t anyway to randomize the object returned by ‘mysql_query’. So in an effort to prevent myself from forgetting this easy fix I’m documenting it here. I also hope it helps someone else.
Goddamn. I can’t believe I forgot something that simple … it’s like forgetting how to tie your shoes.