- This topic is empty.
September 2, 2008 at 11:47 pm #23167
I am currently making a website for an online radio station. I am trying to find a way to have what program is currently on, which changes dynamically, depending on the time. Eg:Quote:John Smith – My Radio Program
I’m guessing i need to use PHP, but am really not sure even where to begin. Can anyone help?September 3, 2008 at 3:03 am #49529tcindieMember
Probably the best solution would be PHP and a fairly simple database
My thought would be to create a database like this:
ok, now say you’ve got show X that’s on from 9am to 11am on Monday, Wednesday and Friday… you’d create a record in the show info table with the name/info of that show, it’s start time and end time… In the SHOW_DAYS table, we’ll assume day ids are 1-7 for Sunday – Saturday…
If show X has an id of 1, then the entries to the SHOW_DAYS table would be 2,1 4,1 6,1 That’s show id 1 on days 2,4, and 6 (mon, wed, and fri)… Suppose this same show has a different time slot on a different day of the week, well with this database model you’d have to create a different entry in the SHOW_INFO table.. there are more streamlined ways to handle it, but since there isn’t likely to be an outrageous number of shows to deal with, it’s probably not a huge deal.
ok, then your php script on the page would check what the current time is (on the server) and what day of the week it is, then run a query against the database to pull the show name where the start time is < the current time, and end time is > the the current time, and the show ID is within the list of show ids matching the days in the SHOW_DAYS table..
the sql would look something like this:Code:SELECT show_name from SHOW_INFO as S, SHOW_DAYS as D where D.day_id = $day and S.id = D.show_id and $current_hour > S.start_hour and $current_minute > S.start_minute and $current_hour < S.end_hour and $current_minute < S.end_minute;
That will return just the show name of the show currently on the air. If you wanted it to return the times as well, then you’d have to add those to the select statement, as such:Code:SELECT show_name, start_hour, start_minute, end_hour, end_minute from SHOW_INFO as S, SHOW_DAYS as D where D.day_id = $day and S.id = D.show_id and $current_time > S.start_time and $current_time < S.end_time;
The php code could basically be something along these lines:Code:
Of course you would also need to add the code to open a connection to the database, issue the select statement, and print the output, but that’s all pretty standard stuff that can be found easily by looking through the online manual at php.net… I’ve covered all the difficult bits here for you. ;)
There’s a couple other benefits afforded by going to this length to handle the stuff you’re after…
September 3, 2008 at 3:50 am #49530
- Visitors could be presented with daily and/or weekly lists of when shows are on the air. These would be dynamically generated.[/*:m]
- Visitors could search the listings by day/time or show name (ideally by supplying them with drop down lists to select from)[/*:m]
- Station manager(s) could make use of the same database for scheduling of shows. Any changes would then be immediately reflected on the website.[/*:m][/list:u]
Of course this is a very basic implementation of what you’re after, it could be expanded greatly to handle seasonal programs, etc.. this could also be tied in to a program archive… the limits are really only determined by how far you want to expand it….
Hope that helps
Without modification to handle adjustment for visitor timezones that would only be accurate for people in the same timezone as the radio station.. most likely those are the only people listening to the station anyway, but there’s not sense is putting out a website that’s broken for everyone else on the web. ;)September 4, 2008 at 11:21 am #49561
- The forum ‘Other’ is closed to new topics and replies.