outputting results in a random order with MySQL and PHP

Hi experts,

I have a form which gives the user an options as to how to display the results: the latest entry, most highly rated, and randomly.  With the fields I have, the first two can be done with a simple ORDER BY command in the sql, but outputting the results in a random order is a little more complex... I'm assuming that there isn't an SQL statement which will do this, so any idea on some PHP which might build the results randomly, e.g. into an array?

Thanks!
RowdyBurnsAsked:
Who is Participating?
 
frindoCommented:
Well if you put your results into an array you can use the "shuffle()" api to mix up the array and then output the values...

See more in the api manual: http://us.php.net/shuffle
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.