PHP Questions Home | Register | Login
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website
Unanswered

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

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");
?>



Comment on this Question and Answer >>>

ASK A QUESTION

More mysql PHP Questions

How do I find the number of rows in a result set?

How do I include a conditional in my mysql query?

How do I find the ID of a new row added to a table?

How do I connect to mySQL from PHP?

How do I return the date with mySQL?



Custom Search