FORUMS: list search recent posts

radio site

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
velocity
radio site
on Jun 22, 2005 at 11:09:55 pm



hi, i am in the process of creating a site for a radio station, and they want a line of text to load from the timetable showing what show is currently on that updates dynamically. is there an easy way to do this? please help, my deadline is fast approaching.....Thanks...


Return to posts index

Curtis Thompson
Re: radio site
on Jun 22, 2005 at 11:14:39 pm

hello...

short answer: yes. there are a ton of ways to do that - unfortunatley, you didn't get into your personal scripting experience or other related bits that could be helpful in answering your question... :-/

you can get into having this info in a database, although something as simple as a tab-delimited text file with one show per row might do as well - then use any basic scripting language (perl, php, asp, etc.) to read the file and show the appropriate content based on the current date and time...

and if the schedule really doesn't change that much, you could consider just storing it in a javascript array and just using that to figure out what to show. the database/tab file is easier for non-techies to edit, but it might end up being overkill if the schedule is pretty consistent...

sitruc


Return to posts index

velocity
Re: radio site
on Jun 23, 2005 at 12:16:35 am

Thanks for yr reply..... I have pretty much no scripting experience, as i use flash for everything..... but this needs to be non flash... the timetable is in excel format, but could be a txt file..... i was told to do something like this:


//The hour of the day it is, from 0-23
$time = date("G");

$query = "SELECT `B,13` FROM `timetable.xls` WHERE `id`='$time'";
$result = mysql_query($query);
$result = mysql_fetch_array($result);

?>



NOW PLAYING



but i cant make it work.... what am i missing????


Return to posts index


Curtis Thompson
Re: radio site
on Jun 23, 2005 at 12:22:36 am

hello...

sorry - still missing info...when you say it won't work, what do you mean? like the wrong data shows up? no data? script won't compile?

i don't think it's going to work with this:

$query = "SELECT `B,13` FROM `timetable.xls` WHERE `id`='$time'";
$result = mysql_query($query);
$result = mysql_fetch_array($result);

i've never seen a sql select running on an xls file like that and mysql_query will only typically run against a mysql db...

sitruc


Return to posts index

velocity
Re: radio site
on Jun 23, 2005 at 12:32:44 am

Thanks for yr reply...... do you know of a way to do it? I have a .xls timetable and need a script that displays what show is on based on what time it is..... i am a total scripting novice and its doing my head in..... thanks much...:}


Return to posts index

Curtis Thompson
Re: radio site
on Jun 23, 2005 at 12:53:33 am

hello...

this guy supposedly has written an xls file reader for php (by default php doesn't do this):

http://www.paggard.com/projects/xls.reader/xls_reader_help.html

but it is oop programming so without scripting experience it might be a little overwhelming...but actually his code looks rather straightforward.

if the xls file doesn't change often, then it would be much easier to export it as tab-delimited data or as a csv file and then php can read that easily...there, you just load the file via a file call and loop through the contents until you find the match.

alternately, you could transfer the content to a database and read it that way.

so yes - i do know how to do it and there are many ways _to_ do it, but all involve at least a bit of scripting knowledge. without seeing your xls file or knowing if you have the option of converting it to csv or the likes or putting it in a db, i cannot offer a specific solution to fit your needs. if you can do the csv or db route, it is no more than 20 lines or so of code. if it's for a home page on a high-traffic site, you might want to consider the db route as it will be faster in the long run...

sitruc


Return to posts index


velocity
Re: radio site
on Jun 23, 2005 at 1:00:18 am

ok, so i have saved it as timetable.csv..... the "A" column is the time and the "B" column is the content...... what script do i need to display an updating line of txt?
thank you so much for your help....
Ben.


Return to posts index

Curtis Thompson
Re: radio site
on Jun 23, 2005 at 1:06:11 am

hello...

you need to do a basic open file script and put the contents into an array:

http://us4.php.net/manual/en/function.file.php

then you need to analyze the time column and compare the time in that to now - this is typically done by comparing timestamps (seconds or sometimes milliseconds since jan 1, 1970). you can do that with the current time via this:

http://us4.php.net/manual/en/function.time.php

and then if your csv file has a typically-formatted date, you can use strtotime to convert it to a time value:

http://us4.php.net/manual/en/function.strtotime.php

if not, you'll need to parse it manually with substr to get out the bits to make a time value:

http://us4.php.net/manual/en/function.substr.php

then using the basic example from the file call listed first above, you can iterate through the lines of the csv file and test each time value against your current time value - if it matches, you note the content value and break the loop (important to help performance) and then show the content via something like you had posted in your first example a few posts ago...

make sense?

sitruc




Return to posts index

velocity
Re: radio site
on Jun 23, 2005 at 1:16:08 am

right so... sorry for my stupidity by the way...... this is what i have now....
when i preview it it says " $line) { echo "Line #{$line_num} : " . htmlspecialchars($line) . "
n";

and that is all...


// Get a file into an array. In this example we'll go through HTTP to get
// the HTML source of a URL.
$lines = file('timetable.csv');

// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
echo "Line #{$line_num} : " . htmlspecialchars($line) . "
n";
}
$nextWeek = time() + (7 * 24 * 60 * 60);
// 7 days; 24 hours; 60 mins; 60secs
echo 'Now: '. date('Y-m-d') ."n";
echo 'Next Week: '. date('Y-m-d', $nextWeek) ."n";
?>
echo strtotime("now"), "n";
echo strtotime("10 September 2000"), "n";
echo strtotime("+1 day"), "n";
echo strtotime("+1 week"), "n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "n";
echo strtotime("next Thursday"), "n";
echo strtotime("last Monday"), "n";
?>



Return to posts index


velocity
Re: radio site
on Jun 23, 2005 at 1:34:21 am

Hi again..... so do i put all that code into an html pg? or put eg:

// Get a file into an array. In this example we'll go through HTTP to get
// the HTML source of a URL.
$lines = file('timetable.csv');
?>

and save it as test.php
and then call it from another html pg? if so how do i call it?

this is driving me crazy... thank you so much for your help, i usually work in flash, and my head doesnt seem to get scripting at all....


Return to posts index

Curtis Thompson
Re: radio site
on Jun 23, 2005 at 2:24:52 am

hello...

it's hard to answer all these w/o the context of your actual file...

i've seen your csv example from the other post - i think it will just be easier for me to write you an example rather than try to help you with your existing stuff when i'm so removed...

give me 30 minutes or so...

sitruc





Return to posts index

velocity
Re: radio site
on Jun 23, 2005 at 1:06:49 am

csv file looks like this.....


Monday,,,
1 - 3pm,Solid Drumnbass w Puffvader
3 - 5pm, GND Drive Show w Don Luchito and Nafski
5 -7pm,Basssrop Radio w Uknw & weekly guests
7 - 9pm,Eternal Groove w Mish
9 -11pm,Psyd Show w Inner Eye Crew
Tuesday,,,
10 - 1pm,Redbird Radio w Redbird Jnr
1 - 3 pm,NZ Release Show w Redbird Jnr
3 - 5pm,Cable
5 - 7pm,Tuesday Sessions w Fidjit
7 - 9pm,"Live on Stage w Flux, Ddog & Guests"
9 - 11pm,Bevan - Ryder
11pm - 1am,Maia


etc...


Return to posts index


Curtis Thompson
Re: radio site
on Jun 23, 2005 at 3:30:35 am

hello...

this is much messier than it needs to be due to the rather lax formatting of the time values (like no am/pm for the first time, which requires a lot more logic to figure out what it should be) - but that said, this should be a functioning example:

http://sitruc.com/cow/radio_schedule/

the schedule.csv is a full schedule, the schedule.php is the script and the other one is the schedule.php code in a plain txt file...

tested it with a few varieties of things and it seemed to work ok - again, it would be _immensely_ easier if the times were more structured (i.e. "11am - 1pm"), but this should compensate for the current times. but also note that if you change the format of the file, it might break this script - because of the free-flow nature of the times and day rows, this looks for very specific patterns to properly extract data (it's the only way it can work, really)...

sitruc


Return to posts index

velocity
Re: radio site
on Jun 23, 2005 at 4:42:37 am

a thousand thanks...... saved my deadline!!! many many thanks for your time..... have a great day...
Ben.


Return to posts index

Curtis Thompson
Re: radio site
on Jun 23, 2005 at 6:03:12 am

hello...

no problem - be sure to post the site url when you get it done!

sitruc


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]