Need help with php script

Discussion in 'PHP' started by eamong, Aug 30, 2010.

  1. #1
    I am looking for a help to make a script which will get football results from url and display them in table view
     
    eamong, Aug 30, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    What help do you need, post what you have so far, or try the programming section.
     
    MyVodaFone, Aug 30, 2010 IP
  3. clorets01

    clorets01 Peon

    Messages:
    91
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    As it was suggested, post what you have so far. To fetch data from another website, you might want to look at php's curl functions
     
    clorets01, Aug 30, 2010 IP
  4. eamong

    eamong Well-Known Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    108
    #4
    <?php

    $url = "http://footballstats.telegraph.co.uk/FixturesResults10.aspx";

    $raw = file_get_contents($url);

    $newlines = array("\t","\n","\r","\x20\x20","\0","\x0B");

    $content = str_replace($newlines, "", html_entity_decode($raw));

    $matches = explode("class='frMatch'",$content);
    foreach ($matches as $match){
    $match = str_replace('<a ','<span ',$match);
    $match = str_replace('</a>','</span>',$match);
    if( stripos($match,$_REQUEST['team'])!==false){
    $match = str_replace('>Match Report</span>','></span>',$match);
    echo $match;
    }


    }
    ?>

    I need to display the results team=xxxxxxx in table view
     
    eamong, Aug 30, 2010 IP
  5. Monotoko

    Monotoko Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I would advise writing the data that you get to a .csv file, then you can use this snippet of code to turn the .csv into a table:

    You might also want to use cURL instead of file_get_contents, its faster and will speed up your script :)
    The first function was written by myself for another application
     
    Monotoko, Aug 30, 2010 IP