I'd like to be able to pull a random quote from my db everytime user visits the page. What's the best way of doing it?
A selection must be from particular number of quotes that meet certain parameter set in that db...
It depends on how your database is structured and you have to say what is this "certain parameter".
umm id say get your info into an array() the i wouldnt know how to randomize it.
Let's say that each quote is associated with a particular magazine issue and each issue clearly has a publication month.
Then I'd like to display a quote from a a particular issue, but random one. Shall I get all quotes ids and put them in an array and then somehow "magically" pick one?
😕
That's one way. Once you have the array, just do a: $selection = $array[mt_rand(0, count($array) - 1)]; or $selection = $array[array_rand($array)];
Alternatively, you could try a SELECT ... ORDER BY RAND() LIMIT 1;
Wow laserlight!
I think I like the last one, but I'll consider them all to get the best one.