Karen
|
| Posted: 03/03/2003, 12:40 AM |
|
I'm trying to display a random record for each day as a tip of the day thing. I have no problem selecting a random record but how do I also select the record that has been displayed for the day already? Here's what I've done so far.
I've created a table with the tips and date. The tips are then selected randomly (using custom SQL) and one is displayed in the grid type form. At the same time, in the Before show event, I update the date field to today's date.
Now the problem is for the same day, I don't need to select randomly again. I just need to select the record that matches today. I'm not sure how to put this condition into the custom SQL.
So basically here's what I need to do, I have 2 select statements. I will only execute the second if the first does not return any results. Can anyone tell me how to go about this? Or I'm not going about it the correct way in the first place. Pls help!
|
|
|
 |
folkerts
|
| Posted: 03/03/2003, 1:20 AM |
|
You could use a xtra field in your table TipOfDay call this field last_used. When someone hits your page your script starts searching for a tip of the day where date last_used is today. if this query return Null you should make a tip of the day. This way you cann make sure the same tip isnt displayed within a week off lastused etc.
have fun
folkerts
|
|
|
 |
|