Jump to content

Archived

This topic is now archived and is closed to further replies.

DarkHorizon

Displaying random records from database

Recommended Posts

If i have a mysql database with 10 items in it. How do i display any 3 at random?

 

Every time the front page loads on my website i need 3 random products to appear.

 

I know how to display and sort databases, its the statement to retrieve a random items that is confusing me..

 

cheers guys..

Share this post


Link to post
Share on other sites

SELECT * FROM `table` ORDER BY RAND() LIMIT 3

Share this post


Link to post
Share on other sites
SELECT * FROM `table` ORDER BY RAND() LIMIT 3

302251[/snapback]

 

cheers mate, i'll give that a try

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.