randomising a quote from mysql
Posted 09 June 2003 - 04:13 PM
Posted 09 June 2003 - 06:12 PM
like if have a unique ID to refer this quotes say u have 200 quotes and they have field say quote_id from 1 -200
u can use PHP rand() or srand() to select a number randomly and pass that to query.
Posted 09 June 2003 - 10:07 PM
With the more current versions of php you suppossedly don\'t need to seed rand with srand.
I would select min(quoteid), max(quoteid) from yourtable first, then use those values to pass to rand:
$randid = rand($minval, $maxval);
Then as Shiv suggested just do a select quote from yourtable where quoteid = $randid
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users