> I am working on an app that needs to post information to a website
> based on date. The tricky part for me is that the date is a range that
> spans either 2 or 3 days. I want the web page to dynamically populate
> information based on a query. The query will look something like this:
> mysql("Calendar2","SELECT StartDate, StopDate, LocationID FROM
> phpCalendar_Daily WHERE StartDate=CURDATE() ")
> My question is say for example the StartDate is actually Jan. 1.
> The page is accessed on Jan. 2 or Jan. 3... The StartDate for the next
> entry is Jan. 4. How do I write this query to select the proper entry?
> doing some research, it appears that a MySQL "SELECT CASE" might do the
> trick, but I have never used this before. The other option I can envision
> is using PHP to handle the login and simply running the query, testing the
> result, if NULL, run the query again with CURDATE(-1).
> Any hints, ideas, or suggestions would be most appreciated. Thanks
> in advance.
If I understand you correctly, I think you could use something like this:
SELECT StartDate, StopDate, LocationID FROM phpCalendar_Daily WHERE
StartDate BETWEEN CURDATE() AND CURDATE() - INTERVAL $x DAY
Where $x is 2 or 3, depending on your case.
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php