Hi,
anyone knows how to randomize a selection I took like
"select * from table where x='y'"
??
Regards, Apoc-
I have the feeling there is a MySQL function for this but I', not sure so you could try using the rand() and srand() runctions (better check the manual for specifics) and perhaps choosing an array index as the random element.
Nick
Are you trying to randomize the order in which the data is retrieved - if so count the record then use mysql_data_seek()called with a random number generated between 0 - count, this will select a random record.
hope this helps
How about doing something along the lines of...
$sql = "SELECT a, b, c, ".rand(10000)." as ord" $sql .= "FROM x ORDER BY ord"
Don't have access to PHP/MySQL at the moment to try it...
Scratch that.. It won't work.. D'oh!
SELECT a, b, c, rand() as ord FROM x ORDER BY ord
should do the job...
sorry this didn't help, thanks anyway. What i want to do is to randomize a selection i took from a table, or randomize it in the same moment i take it.
would shuffle_array on the result work ?
I figured out why rand() didn't work ... my damn hoster uses an old mysql version which doesn't support rand() properly - thanks for everything anyway!
P.S: visit my site: www.engineersnet.de - german though