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 ID of a new row added to a table?

how can I show an image from mysql?

How do I set a default value for ENUM fields in PHP?

How do I limit the number of rows returned?

My website www.quicheandpie.com has navigation buttons which were added by going to admin/categorylist and adding a category. I can add category = navigation buttons and update them, but I can not delete them. Any ideas how I can find where the info



Custom Search