Improved stock ticker
This version allows users to enter the company name and it displays the corresponding ticker symbols.
Here is the updated code
<form action="<? echo($PHP_SELF); ?>" METHOD="POST">
<input type="text" name="company">
<input type="submit" NAME="action" value="Submit">
</form>
<?php
if ($action)
{
//this is the company you wish to lookup
//$company = "";
//this is the url from yahoo + the company
$url = "http://quote.yahoo.com/l?m=&s=$company&t=";
//open the url and store in $fp
$fp = fopen($url , "r");
//read 20000 bytes of the file
$readfile = fread($fp , 20000);
//search for the HTML below and store everything in between in $content
$readfile = ereg("<TABLE border=0 cellPadding=2 cellSpacing=0 width=100%>(.*)<small>Add</small>" , $readfile, $content);
//display the results in a table
echo "<table width = '100%'>";
echo "$content[1]";
echo "</table>";
//close the file handle
fclose($fp);
}
?>
Try it out here