| ||||||||||||
Radio Station site Posted by bschultz (bschultz), 18 July 2004 Hi Everyone!I've got a couple questions. I work at a radio station (news and talk), and I'd like to simplify my life a little. I've written a php script to display "who is on the air now". It's only based on time of day and day of the week. We have lots of "special" programming that changes from week to week (mainly sporting events) that I REALLY don't want to have to change in the php script every week. Would a mysql db that has the programming for the month work as well as I'd like it to...(I THINK it will, but I haven't used many of the "extras" in mysql)? On a somewhat related topic...we are able to stream our audio online for local programming only. If we get the show from a syndicated source, we can't stream it. Programming the streaming software as to when it can be streamed and when it can't be streamed is a PAIN IN THE BUTT! I'd like to disable the url to the stream if we can't stream that program. Is that possible in mysql (or any other language) I've only used php and mysql (a little)...so I'm sure that what I'm asking is possible...I just don't know where to look and what language to look at. Thanks for the help. Brian Posted by admin (Graham Ellis), 3 August 2004 Oh yikes - I missed this post so my reply is a little tardy. Most have slipped through the net when I was in Rome for a few days. Hopefully "better late than never".I would think you can do most of what you want with date specific PHP scripts - simply use functions like time or date to work out when the script is bieng run, and then adjust the output accordingly. A MySQL database might work well for you, or you might find it easier simply to maintain a text file into which you place all the times / dates / events you want on the site. We use such a scheme for copyright and course dates througout out own site so that we're not advertising events that are long-passed, even if the data remains on the server On the streaming question, you can't really "disable" a URL - well - I suppose you can, but you don't want to as people will get an ugly "403" or "404" depending on how you do it. Better to replace the page with a PHP script that refreshes to the audio feed, or comes up with an explanation as to why no feed is available. I guess you can be really clever and have the PHP script turn the feed on or off each time it's run, thus ensuring that anyone who directly bookmarks the feed will find it's turned off pretty quickly (by another user) when you move from local to syndicated programming, and vice versa. You ask what language - PHP!!!!!! You know some PHP already and it can do an excellent job for you. No point in learning an alternative. Posted by bschultz (bschultz), 3 August 2004 thanks, Graham...You're right, better late than never. I've already implamented a php script but I'm still leaning toward a database for ease of changing what needs to be changed from week to week. Thanks for solidifying my choice (and for the email!). Brian Posted by bschultz (bschultz), 14 September 2004 It's been a while since I've had any time to work on this. I still don't like how many steps there are for changing a program from week to week. Here's a snipet of code for one showCode:
I have that for each show, for each day of the week. The script is 800 lines long! I'll admint that it's been so long since I've dealt with php, could you point me in the right direction for using a text file? I think that would be a much simplified solution than a database. Thanks. Brian Posted by admin (Graham Ellis), 14 September 2004 A database is usually preferable as it would lead you to a file that can be maintained (and have its integrity maintained) by some standard applications such as phpmyadmin - however, you have the special case of a piece of code and data file that's going to be looked after by just you.I happen to be running a PHP course in about 4 hours (see http://www.wellho.net/course/phfull.html - sorry about the ad), so I've take the opportunity to get into gear by writing an example program - I cut and pasted your code and added a data file containing a program listing. Here's the program: Code:
and here's the datafile that goes with it Code:
I've briefly tested this - it's on line at http://www.wellho.net/demo/radio.php4 and the sample data is in the same directory. Please feel free to use this as a basis / copy / update / modify / extend for your own use. Beware that it is VERY easy to get the data wrong in the format adopted, and that you need to consider time zone issues (our server for this demo is in California) ... that's why I've had my demo tell you what it thinks the time is for when you try it out. Posted by bschultz (bschultz), 14 September 2004 Thanks for the code, Graham. Just so that I'm sure I follow what you've done:Quote:
1-5 is the days of the week...0-4 is the hours that the show is on? Is that right? I don't need to worry about time zones, since the server is right down the hall from my office. Thanks again, Graham. Brian Posted by admin (Graham Ellis), 14 September 2004 Yep, you've read that right "1-5,0-4" is Monday to Friday, midnight to 04:59 a.m. Posted by bschultz (bschultz), 14 September 2004 thanks, Graham. I'll tweak the code to suit my needs, and I'll repost the code for others.Thanks again! I'm always amazed how helpful you are! Posted by bschultz (bschultz), 27 April 2005 I just realized that I never posted my code for this. I did, in the end, decide on a database for ease of editing.Code:
As a note, $days and $hours are the days and hours the show is on the air...it just gets echoed onto the page. If you want to see it in action, visit http://kkbjam.com Thanks again, Graham Brian This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
| ||||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |