The script is used to import share prices from yahoo and displaying these on a webpage at at http://www.johnrogers.com.au/quotes3.php
I then import this information into a lotus spreadsheet.
The script works quite well except that the table displays twice.
I should add that I do not really understand php scripting. Any help in solving the above problem would be greatly appreciated. The script is as follows:-
Code: Select all
<?php
function show_stock_quotes ($stock_list) {
if (! $stock_list) {
$stock_list = "CEY.AX,DOW.AX,ELD.AX,OZL.AX,SUL.AX,CCV.AX";
}
$url = "http://quote.yahoo.com/d/quotes.csv?s="
. $stock_list . "&f=sl1c1&e=.csv";
$filesize = 2000;
$handle = fopen($url, "r");
$raw_quote_data = fread($handle, $filesize);
fclose($handle);
$quote_array = explode("\n", $raw_quote_data);
echo "<table border=1>";
echo "<th>Company</th> <th>Price</th> <th>Change</th>";
echo "</tr>";
foreach ($quote_array as $quote_value) {
echo "<tr>";
$quote = explode(",", $quote_value);
$symbol = str_replace("\"", "", $quote[0]);
$value = $quote[1];
$change = $quote[2];
echo "<td>$symbol</td> <td>$value</td> <td>$change</td>";
echo "</tr>";
}
echo "</table>";
}
?>
<?php
$symbol_list = str_replace("\n", ",", $_REQUEST["symbol_list"]);
$symbol_list = str_replace("\r", ",", $symbol_list);
show_stock_quotes (False);
show_stock_quotes ($symbol_list);
?>