This is an update to a previous post of mine which uses the RAND() method. Using the following code, you can retrieve a random row much, much faster (MySQL 4.1.x/5.0.x), with thanks to Jan Kneschke:
SELECT <COLUMN> FROM <TABLE> AS r1
JOIN (SELECT ROUND(
RAND( ) * (
SELECT MAX( id ) FROM <TABLE>)
) AS […]
UPDATE: Please see my newer atricle on how to retrieve a random row, faster, without RAND().
This post assumes you know how to create and use a connection to a MySQL database in PHP and have a table named 'quotes' as shown below. In this post, I will aim to teach you how to use PHP […]