• home
  • forum
  • my
  • kt
  • download
  • yahoo stock quote (csv file)

    Author: 2007-08-24 18:27:47 From:

    Yahoo stock quotes from a csv file
    <?php
    //stock quote script
    //this is the url for Microsoft's stock quote , we are opening it for reading
    $fp = fopen ("http://finance.yahoo.com/d/quotes.csv?s=msft&f=sl1d1t1c1ohgv&e=.csv","r");
    //this uses the fgetcsv function to store the quote info in the array $data
    $data = fgetcsv ($fp, 1000, ",")
    ?>
    <!-- this is our table which displays the stock info -->
    <!-- we access the individual items by using $data[0]-->
    <table>
    <tr><td>description</td><td>latest figure</td><tr>
    <tr><td>symbol</td><td><?php echo $data[0] ?></td></tr>
    <tr><td>last price</td><td><?php echo $data[1] ?></td></tr>
    <tr><td>date</td><td><?php echo $data[2] ?></td></tr>
    <tr><td>time</td><td><?php echo $data[3] ?></td></tr>
    <tr><td>change</td><td><?php echo $data[4] ?></td></tr>
    <tr><td>open</td><td><?php echo $data[5] ?></td></tr>
    <tr><td>high</td><td><?php echo $data[6] ?></td></tr>
    <tr><td>low</td><td><?php echo $data[7] ?></td></tr>
    <tr><td>volume</td><td><?php echo $data[8] ?></td></tr>
    </table>
    <?php
    //close the filehandle $fp
    fclose ($fp);
    ?>

    descriptionlatest figure
    symbolMSFT
    last price28.30
    date8/23/2007
    time4:00pm
    change0.00
    openN/A
    highN/A
    lowN/A
    volume0

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      Ad Management (4)
      Calendars (3)
      Chat Systems (7)
      Content Management (6)
      Cookies and Sessions (8)
      Counters (8)
      Database Related (8)
      Date and Time (9)
      Development (6)
      Discussion Boards (7)
      E Commerce (6)
      Email Systems (9)
      Error Handling (5)
      File Manipulation (10)
      Flash and PHP (4)
      Form Processing (7)
      Guestbooks (8)
      Image Manipulation (3)
      Installing PHP (5)
      Introduction to PHP (9)
      Link Indexing (6)
      Mailing List Management (8)
      Miscellaneous (10)
      Networking (6)
      News Publishing (6)
      OOP (8)
      PEAR (6)
      PHP vs Other Languages (2)
      Polls and Voting (5)
      Postcards (0)
      Randomizing (8)
      Redirection (8)
      Searching (6)
      Security (6)
      Site Navigation (7)
      User Authentication (10)
      WAP and WML (7)
      Web Fetching (0)
      Web Traffic Analysis (11)
      XML and PHP (0)

    New

    Hot