[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

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!
0
RowdyBurns
Asked:
RowdyBurns
1 Solution
 
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

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now