First off, hello. This is my first thread on this forum and it appears to be a very helpful resource for people ranging from beginner to advanced coders, I look forward to contributing as well as receiving advice from members.
That said, I am wondering how I would go about doing this properly...
Here is my current code...
Code:
<?
$row = 1;
$handle = fopen("http://finance.yahoo.com/d/quotes.csv?s=XTO+CHK+XOM+MSFT&f=snkcp4", "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "\n";
$row++;
for ($c=0; $c < $num; $c++) {
echo "<span style=\"";
if ($data[$c]>0) {
echo "color: #009900\">";
}
elseif ($data[$c]<0) {
echo "color: #990000\">";
}
else {
echo "font-weight: bold\">";
}
echo $data[$c] . "</span>  -  \n";
}
}
fclose($handle);
?>
Currently the code calls for anything below zero to appear in red text to reflect adjustments in stock prices, and anything above zero to appear in green text... ideally, I would only want the [4th] column in every row to be displayed with these attributes.
Example: CSV appears as follows...
MSFT,Microsoft Corp,27.74,-0.01 --0.01%
GOOG,Google,450.00,+1.45 -+0.87
Any help would be appreciated. 
Last edited by FRAZL; 09-11-2009 at 02:36 PM..
|