Snippet Name: Display stock quotes from a CSV file
Description: Displays formatted stock quotes from a dynamically retrieved CSV file.
Comment: (none)
Language: PHP Highlight Mode: PHP Last Modified: March 01st, 2009
<?PHP// 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><?PHPECHO$data[0]?></td></tr>
<tr><td>last price</td><td><?PHPECHO$data[1]?></td></tr>
<tr><td>date</td><td><?PHPECHO$data[2]?></td></tr>
<tr><td>time</td><td><?PHPECHO$data[3]?></td></tr>
<tr><td>change</td><td><?PHPECHO$data[4]?></td></tr>
<tr><td>open</td><td><?PHPECHO$data[5]?></td></tr>
<tr><td>high</td><td><?PHPECHO$data[6]?></td></tr>
<tr><td>low</td><td><?PHPECHO$data[7]?></td></tr>
<tr><td>volume</td><td><?PHPECHO$data[8]?></td></tr>
</table>
<?PHP//close the filehandle $fp FCLOSE($fp);?>
SQL University.net courses meet the most demanding needs of the business world for advanced education
in a cost-effective manner. SQL University.net courses are available immediately for IT professionals
and can be taken without disruption of your workplace schedule or processes.
Compared to traditional travel-based training, SQL University.net saves time and valuable corporate
resources, allowing companies to do more with less. That's our mission, and that's what we deliver.