• Home
  • Log
  • Projects
  • Gallery
  • About
  • Contact

Brain Fart.

June 8th, 2006

Considering 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.

Posted in Programming |


Leave a Reply

  • Pages

    • About
  • Archives

    • October 2008
    • November 2007
    • November 2006
    • October 2006
    • August 2006
    • July 2006
    • June 2006
    • April 2006
    • March 2006
    • February 2006
    • January 2006
    • December 2005
    • October 2005
    • May 2005
  • Categories

    • Uncategorized (1)
    • Music (1)
    • Graphics (3)
    • Programming (8)
    • Misc (15)
    • Travel (3)
    • Linux (3)
 Use OpenOffice.org

Powered by WordPress Entries (RSS)
and Comments (RSS). 14 queries. 0.248 seconds.