Retrive record based on day of week


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.

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.

No, you’d use a standard query which included your day as the where condition.

SELECT ID, title, desc, price, dayofweek
FROM yourTable
WHERE dayofweek = $today

(having previously said $today = date(“l”); )

Not an if…else in sight (or site)

found something for anyone looking to do this:

thanks Dr.John simple enough. I’ll give it go.