I wanted to randomly select results from mysql database with this code:
$data = mysql_query("SELECT * FROM people ORDER BY RANDOM() LIMIT 4") or die(mysql_error());
I got an error message: FUNCTION members.RANDOM does not exist
Is there something I'm not adding or doing right here?
Thanks for your asistance.
The function name you're looking for is RAND().
You need ORDER BY RAND()
$data = mysql_query("SELECT * FROM people ORDER BY RAND() LIMIT 4") or die(mysql_error());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With