Ok, this is something thats been bugging me for a while.
In the past ive built for loops and generated random numbers and when found the location that corrosponds to that number returned the row... that is actually stupidly wasteful.

Especially when if i hadnt been so lazy and just searched the web for an answer i could have made things easier.

Anyways, enough babbling, here is a simple MySQL implementation that will return a random row.
<?php

$query = "SELECT * FROM tablename ORDER BY RAND()";

?>
YES! Thats it, its that easy. Just use the RAND() function and your laughing...

Posted by OLLIE at 21:55pm

No comments yet. Be the first to add one!


Leave a Reply