Hi there,
I want to select one record randomly, how can I acheive my goal?
Please help.
I would try something along the lines of
SELECT * FROM table ORDERY BY RAND() LIMIT 2
For more info. I would do a search. This topic as been answered many times.
Thanx for your help, I made minor changes 🙂
SELECT ID FROM TABLE ORDER BY rand();
But now I have different question 🙂
How can I make this query select random ID everyday not every page load?
I guess one way I might try is storing a date in a date table and when the page gets accessed just have it check to see if todays date matches the one in your database.
<? $q = "SELECT * FROM date_tbl"; $r = mysql_query('$q'); $row = mysql_fetch_array($r); $thenDate = $row[date]; $todayDate = date("Ymd"); if($thenDate != $todayDate) { RUN YOUR QUERY HERE AND HAVE ANOTHER QUERY UPDATE THE THE STORED DATE TO THE CURRENT ONE. }