Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 3 123 LastLast
Results 1 to 15 of 32

Thread: time table

  1. #1
    New Coder
    Join Date
    Jun 2006
    Location
    eth0
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts

    time table

    hi everyone,

    can someone help me out with this script i'm making?

    basicly i have a bus timetable, and i want the script to show the 2 nearest buses and if I enter an hour, that it would also show the 2nearest buses for that inputed time.

    i've tried using sscanf and other strings, but couldn't get anything done!..
    <? print("Hello World") ?>

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,512
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    Well, first of all, you need to show us some scripting you've done so far.

    Secondly, this sounds like a homework assignment, and we don't
    do people's homework.

    If this is a real website PHP project, give us a link to the site, and also
    some scripting you've done so far ... the script that isn't working.

  • #3
    New Coder
    Join Date
    Jun 2006
    Location
    eth0
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    as I said, nothing worked for me. do you want me to give you useless code that only shows errors?

    this is not homework for Pete's sake. here Sherlock: http://tv.virusas.org
    <? print("Hello World") ?>

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Quote Originally Posted by CodilX View Post
    as I said, nothing worked for me. do you want me to give you useless code that only shows errors?
    Yep, then we can help you sort your code out, tell you where you went wrong, etc.

  • #5
    New Coder
    Join Date
    Jun 2006
    Location
    eth0
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    here's something I'm looking for: http://www.cems.uwe.ac.uk/~cjwallac/...een&refresh=60

    I simply deleted it because it was totally useless, that's why I'm asking for help.
    <? print("Hello World") ?>

  • #6
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Man I had this great post with code to help you, but... I deleted it. Sorry

  • #7
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,512
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    I look more like Dr. Watson ...

    But, anyhow, can we see the database or text
    that you're reading for the bus timetable?

  • #8
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,512
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    This is why I asked if it was homework/school related:

    http://www.cems.uwe.ac.uk/~cjwallac/
    http://www.cems.uwe.ac.uk/~cjwallac/apps/
    http://www.cems.uwe.ac.uk/~cjwallac/apps/bus/

    It just seems like a school project for a programming class ...

    -Dr. Watson-

  • #9
    New Coder
    Join Date
    Jun 2006
    Location
    eth0
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sure,

    well there are different bus times from monday to friday, saturday and sunday. but so far I only need monday to friday.

    Hour Minutes

    5 28 44
    6 00 18 38 56
    7 14 33 55
    8 19 46
    9 29
    10 41
    11 18
    12 09 46
    13 37
    14 19 44
    15 10 28 48
    16 06 26 44 56
    17 16 36 58
    18 18 34
    19 08 15 37
    20 13 50
    21 38
    22 16
    23 03 38
    0 25
    Last edited by CodilX; 04-02-2007 at 05:25 PM. Reason: time table
    <? print("Hello World") ?>

  • #10
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,512
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    OK, I'm done being a smart-alec (I'm just in a punchy mood today) ...

    seriously now ...

    If you have an actual web page that shows the bus timetable,
    you can use PHP to open that page, read the timetable and display
    the closest buses.

    That way, if the timetable changes, you would always be looking at
    the latest schedule.

    This would be similar to an RSS Feeder (using PHP scripting). Would
    something like this be more valuable to you? Let us know and provide
    a URL to a timetable. Even a timetable with every day of the week,
    not just Monday to Friday.

  • #11
    New Coder
    Join Date
    Jun 2006
    Location
    eth0
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well how do I do that?
    <? print("Hello World") ?>

  • #12
    New Coder
    Join Date
    Jun 2006
    Location
    eth0
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <? print("Hello World") ?>

  • #13
    Regular Coder
    Join Date
    Oct 2005
    Location
    Right Here
    Posts
    654
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I suggest picking up a php book or searching for tutorials. Were not gonna write your code for you, especially when it seems you don't even know what php is.

    EDIT: This is a php forum not a asp forum. You trying to trick us into thinking you did that one? Come on... I still think its homework and he didnt pay attention in class LOL!

  • #14
    New Coder
    Join Date
    Jun 2006
    Location
    eth0
    Posts
    68
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you're so smart then give me a link to a tut, cuz i couldn't find one. maybe einstein here has a tut?
    <? print("Hello World") ?>

  • #15
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,512
    Thanks
    8
    Thanked 1,090 Times in 1,081 Posts
    give us a URL to a page with a bus timetable.

    Every HTML page that is parsed is slightly different,
    so there is no "universal" PHP script.

    But this is a simplified example of what happens.
    1) Opens the URL, grabs all data between <html> and </html>
    2) Parses out what is needed between various tags.
    3) Process the info
    4) Display results

    PHP Code:
    <?php

    // Get page
    $url "http://www.google.com";
    $data implode(""file($url)); 
    $time=time();

    // Get Page Content
    preg_match_all ("/<html>([^`]*?)<\/html>/"$data$matches);

    // Loop through each item
    foreach ($matches[0] as $match) {
    // Get title
    preg_match ("/<title>([^`]*?)<\title>/"$match$temp);
    $title $temp['1'];
    $title strip_tags($title);
    $title trim($title);

    // process the HTML, grabbing information
    // and doing calculations for time, etc.

    // Echo Items
    echo "Website Title: $title\n";
    }
    ?>
    EDIT:
    You would open your URL and begin parsing out times ...
    Looking at the URL you provided, the times are really mashed into <table> tags.
    I don't know the website's language, so I can't decipher what the times mean.
    But, the tiny example above is the approach you would take.
    Last edited by mlseim; 04-02-2007 at 06:01 PM.


  •  
    Page 1 of 3 123 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •