atsea_webdesign — 2010-05-16T12:59:58-04:00 — #1
I have a mySQL database setup that has the following fields.
I have config.php to connect to the db, etc. What I want to do is display the record associated with the day of the week.
For instance, if it's Monday show data in reference to dayofweek=Monday. Tuesday, show Tues data.
I know you can use curdate or timestamp but I'm not sure how to build my query for day of the week. Can it be done?
I'm new to php and I'm not sure where to go. If someone could point me in the right direction I'd appreciate it.
atsea_webdesign — 2010-05-16T13:48:05-04:00 — #2
I just read about the dayofweek function. If I use that to determine the day would I then use an if else if statement saying if dayofweek=1 show this ID and it's related fields etc.
dr_john — 2010-05-16T18:10:54-04:00 — #3
No, you'd use a standard query which included your day as the where condition.
SELECT ID, title, desc, price, dayofweek
WHERE dayofweek = $today
(having previously said $today = date("l"); )
Not an if..else in sight (or site)
atsea_webdesign — 2010-05-16T16:33:02-04:00 — #4
atsea_webdesign — 2010-05-17T12:02:03-04:00 — #5
thanks Dr.John simple enough. I'll give it go.