Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Velocity on June 22, 2005 at 11:09 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…

    Curtis Thompson replied 20 years, 11 months ago 2 Members · 14 Replies
  • 14 Replies
  • Curtis Thompson

    June 22, 2005 at 11:14 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

  • Velocity

    June 23, 2005 at 12:16 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:

    NOW PLAYING

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

  • Curtis Thompson

    June 23, 2005 at 12:22 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

  • Velocity

    June 23, 2005 at 12:32 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…:}

  • Curtis Thompson

    June 23, 2005 at 12:53 am

    hello…

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

    https://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

  • Velocity

    June 23, 2005 at 1:00 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.

  • Curtis Thompson

    June 23, 2005 at 1:06 am

    hello…

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

    https://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:

    https://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:

    https://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:

    https://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

  • Velocity

    June 23, 2005 at 1:06 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…

  • Velocity

    June 23, 2005 at 1:16 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…


    $line) {
    echo “Line #{$line_num} : ” . htmlspecialchars($line) . “
    \n”;
    }


  • Velocity

    June 23, 2005 at 1:34 am

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

    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….

Page 1 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy