Jump to content

Filter Content by Week Day and Time Range


rucx

Recommended Posts

I have a back end where I can write new "Stories" which appear on my Frontpage like on a blog.

Now I would like to add a field in the back end where I can define on which days of the week and at what times of those days this "Stories" should be shown on the Frontpage. So lets say, I want Story A to show on Mondays from 15.00-17.00 and from 22.00-24.00 and I want Story B to show from 08.00-12.00.

Any idea how I could achieve something like that with php and mysql?

If your "stories" have an id, you could create a new table called showtimes with the fields id, storyid (as the foreign key), starttime, endtime. Then you would be able to query for any stories where the current time is within the start and end times and display the story if it is. I'm sure there are probably better ways, but maybe that gives you some ideas?

That is why you would create a table for the showtimes only...

 

Then your row data might be

 

id-storyid-starttime-endtime

---------------------------

1 - 2 - Monday 14:00 - Monday 17:00

2 - 2 - Sunday 16:00 - Sunday 18:00

3 - 2 - Friday 22:00 - Friday 23:00

 

This way you could have multiple times for a single story

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.