Your Ad Here

 Navigation
Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Books
Sample Chapters
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links




 Sponsors
 Links
domain names
low cost magazines
golfing products
 Downloads
dzphp editor
EasyPHP
mysql_phpgenerator
php-studio-trial
phpdesigner_7_2_5
phpMyAdmin-3.4.3.2
/phptriad2-2-1
phpxedit_321
rapidphp 2011
WampServer2.1d-x64
WampServer2.1e-x32
xampp-win32-1.7.4-VC6-installer
xampplite-win32-1.7.3
 Misc
Webmaster Resources
Only PHP
ScriptSearch.com
Scripts.com - Get the best scripts NOW!
AndreaPHP Programming

Valid XHTML 1.0 Transitional


Valid CSS!


Display latest stock market prices


Display latest stock market prices

In this example we display the latest stock market information . This example is getting information for the Dow Jones stock market . This is a similar idea to the stock quote script .

Code :

<?php
//this is the url of our csv file
$url = "http://finance.yahoo.com/d/quotes.csv?s=^DJI&f=sl1d1t1c1ohgv&e=.csv";
//open it for reading
$fp = fopen($url , "r");
//if no connection exists display error message
if (!fp)
{
echo "could not connect to the site";
}
else
{
//store the csv file info in the array $data
$data = fgetcsv($fp,1000,",");
//close the file
fclose($fp);
?>
<table>
<tr><td>description</td><td>latest figure</td><tr>
<tr><td>Market</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>
</table>
<?php
}
?>

Example :


Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration in /home/beginne/public_html/marketcsv.php on line 212

Warning: fopen(http://finance.yahoo.com/d/quotes.csv?s=^DJI&f=sl1d1t1c1ohgv&e=.csv) [function.fopen]: failed to open stream: no suitable wrapper could be found in /home/beginne/public_html/marketcsv.php on line 212

Warning: fgetcsv() expects parameter 1 to be resource, boolean given in /home/beginne/public_html/marketcsv.php on line 221

Warning: fclose(): supplied argument is not a valid stream resource in /home/beginne/public_html/marketcsv.php on line 223
description latest figure
Market
last price
date
time
change
open
high
low

 




Books
 Sponsors


 Random Code
Wired news(xml)
PHP captcha example(image)
Display an external RSS feed(Wordpress)
 Random Article
  Network
Programming resources
Tutorials directory
Hosting resources
ASP site
Domain names
Progged
Maxi directory
bigarticle : free articles
A Code
Code N Tutorials
Get PHP
Programmers help




beginners PHP Copyright © 2004 onwards by beginnersPHP.