arrowarrow Shoutbox
 
info In this area you may insert brief and quick contents that you do not deem fit or sufficiently relevant to be placed in your blog. Add new contents: click here
 
arrowarrow Currently available topics
 
Viewing only topics of: Alberto All topics: click here
All topics: 104
Sender: Alberto

Select A Random Entry In A Database With PHP

http://en.wikipedia.org/wiki/File:Miniaturk_009.jpg Saturday March 6, 2010 - 09:13:27
Topic: 86 permalink
Visits: 5,058
'SELECT * FROM foo LIMIT '.(rand(1,$maxNumber)).', 1';  
 
Random selection of a db entry without messing up in the least with queries. It only requires $maxNumber does not exceed the available entries. That easy.  
It took me time to free myself of what we read online or on manuals to achieve that!
Cast your vote for this topic. «Negative Positive»
Click here to save your vote
Current average: 7.00, Voters: 1
Insufficient form parameters: you forgot to fill in some field/s You must reload the page to view the updates You did not cast a vote. You need to cast a vote by selecting a radio button. Impossible to proceed