Ben Sharp

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromBen Sharp
ToMe
Subjecthelp with radio site???
Date21 June 2005 01:54
Hi, I hope its ok to email you, i came accross your site while searching
for a solution to my problem.... I am building a website for a radio
station, and am practicly finished, BUT, they want a line of text on the
page which links to the timetable and clock somehow and displays what show
is currently on.... I have no idea how to do this.....please help!!!!! i
am getting a little worried as my deadline is fast approaching.....
Thanks,
Ben.
FromMe
ToBen Sharp
SubjectRe: help with radio site???
Date21 June 2005 11:21
Ben,

> they want a line of text on the
> page which links to the timetable and clock somehow and displays what show
> is currently on

Assuming the show timetable is kept in a database; you need a server side
script that will read the current show from the database (a query that
retrieves the record whose endtime is greater than now, and whose start time
is before now). A JavaScript can then poll the server every 30 seconds or
so, and retrieve the details.

This page describes how to dynamically pass data to a script:
http://www.howtocreate.co.uk/loadingExternalData.html

As for your clock ... well, that is a little more difficult, as it needs to
know the time on the server, not the user's computer (which may be in a
different timezone). When the page is requested, a server side script can
write a timestamp (make sure it is in miliseconds) into a script.

The script can then use an interval timer to use that to write a clock time
on the screen;
<p id="clockout"></p>
...
var oOffset = (new Date()).getTime() - whateverTimestampTheServerWrites;
function reWriteTime() {
    var oNow = new Date((new Date()).getTime() - oOffset);
    var oStr = oNow.getFullYear()+'-'+(oNow.getMonth()+1)+'-'+
        oNow.getDate()+' '+oNow.getHours()+':'+
        oNow.getMinutes()+':'+oNow.getSeconds();
    document.getElementById('clockout').innerHTML = oStr;
}
setInterval(reWriteTime,1000);


Hope this helps

Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromBen Sharp
ToMe
SubjectRe: help with radio site???
Date22 June 2005 02:57
Hi, thank you so much for your reply... I am still confused.... the time
table is a txt file {or spreadsheet} called timetable.txt , how does it
need to be written?

(a query that retrieves the record whose endtime is greater than now, and
whose start time is before now).

and what script will do this?

thank you very much, my deadline is today and i am stressing out!!!
Ben.
FromMe
ToBen Sharp
SubjectRe: help with radio site???
Date22 June 2005 10:39
Ben,

> the time
> table is a txt file {or spreadsheet}

Urgh! Things like this should be in a database, not in a text file, or
spreadsheet. How is it supposed to cope when the timetable changes? Is some
poor sap expected to generate a new text file every day?

This makes things a lot harder.

SQL databases are ideal for this sort of thing. MS Access is also possible,
but I have never used Access as a server side database, so I would be
completely lost with that.

ok, a text file. It is possible. Use XMLHttpRequest to import the file. Read
out the responseText, parse it manually using string patterns. Make your own
querying control that looks for the current program. If the time exceeds
what is specified in the text file, go and get a new one using
XMLHttpRequest. But this is a _lot_ of work. It will certainly not be done
by your deadline. My XMLHttpRequest script would not cope with this either,
since it expects XML, not plain text. This would all have to be written from
scratch.

>> (a query that retrieves the record whose endtime is greater than now, and
>> whose start time is before now).
>
>
> and what script will do this?

If you used an SQL database, a simple SQL query would do it. PHP scripts
would easily be able to process the data and prepare the page.

If using a text file, you will need to write your own date/time handling
functionality, to check the times for yourself. This is not impossible, but
it is certainly not the easiest thing in the world.

I really would suggest using SQL (try MySQL.com) if at all possible. If not,
considering how much work it would be, you might just want to give up, since
there is no way you could gt this working in a day, even with my help.


Tarquin
FromBen Sharp
ToMe
SubjectRe: help with radio site???
Date23 June 2005 01:07
AttachmentsAn XLS spreadsheet, and an HTML file containing unprocessed PHP that attempts to access the XLS file as a MySQL database (and it uses the backtick operator instead of a quote)
Hi, ok i have a test pg which i have attached along with the timetable, it
is using php which i am bad at, and surprisingly it does not work!!!
please help if you have time... thank you very very much...:}
FromMe
ToBen Sharp
SubjectRe: help with radio site???
Date24 June 2005 10:45
> Hi, ok i have a test pg which i have attached along with the timetable, it
> is using php which i am bad at, and surprisingly it does not work!!!

>>>
$query = "SELECT `B,20` FROM `Timetable.xls` WHERE `id`='$time'";
$result = mysql_query($query);
<<<

Afraid you are way off the mark with this.
xls is not SQL, and cannot be treated as such. Only a real SQL database
can be treated as an SQL database. You would need to install an SQL
database engine on your server, and use that instead of the xls file. If
you want to try this, you can download the mysql database program from
mysql.com and you can also use their tutorial to learn how to use it.

In theory, you can also translate the xls into an access database, which
can then be queried via (I think) ODBC, but I have no idea how to do this.
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.