PHP Questions Home

Categories

Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website


PHP Functions

PHP Functions


More PHP

Top Questions
Ask a Question

How do I return a random row from the database?


If you wish to return a row at random from your mysql database, then simply use the rand() structure in your query, like so:

<?php
$query 
mysql_query("SELECT name FROM millionsofnames ORDER BY rand() LIMIT 1");
?>



More mysql PHP Questions

How do I limit the number of rows returned?
How do I include a conditional in my mysql query?
How do I order the results of my query?
How do I access the current time with mysql?
How do I find the ID of a new row added to a table?