Need modification in a code
Posted: Fri Dec 19, 2008 3:15 pm
Dear friends,
I have been helped in another forums to modify two codes out of which one is working and I need help on the other one.
Working code: It connects to yahoo website and pulls required data based on the string "sl1c1p2ohgpvjk" where:
s=Symbol
l1=Current market price
c1=Change
p2=Change %
o=Open
h=High
g=Low
p=Previous Close
v=Volume
j=52 week low
k=52 week high
My downloadable 3 files from my Yahoo! Briefcase
1.php:http://us.f13.yahoofs.com/bc/4640561dm9 ... JBYGAOPGsK
2.php:http://us.f13.yahoofs.com/bc/4640561dm9 ... JBbzOwjPYe
symbols.txt:http://us.f13.yahoofs.com/bc/4640561dm9 ... JBcePgJeED
Here is the working code:
Another code: It does the same as above. The only difference is that, the above code gets data of only 7 companies and this one gets data of 100 companies. Changes made in this code is that the array is taken from an external "symbols.txt" file and it fetches 50 records in one go because yahoo limits to 50 companies at a time in one query.
I need help on the following:
1. Unable to get data from the second code. It lists the companies but doesn't get the "sl1c1p2ohgpvjk" data.
2. Creates two different tables for 100 companies whereas I want all data in one table so that an user can sort all of them based on his/her requirement.
3. symbols.txt file actually has 106 symbols. It pulls data for first 100 and the last 6 are ignored. How can I get them to show up on the table?
Thank you
I have been helped in another forums to modify two codes out of which one is working and I need help on the other one.
Working code: It connects to yahoo website and pulls required data based on the string "sl1c1p2ohgpvjk" where:
s=Symbol
l1=Current market price
c1=Change
p2=Change %
o=Open
h=High
g=Low
p=Previous Close
v=Volume
j=52 week low
k=52 week high
My downloadable 3 files from my Yahoo! Briefcase
1.php:http://us.f13.yahoofs.com/bc/4640561dm9 ... JBYGAOPGsK
2.php:http://us.f13.yahoofs.com/bc/4640561dm9 ... JBbzOwjPYe
symbols.txt:http://us.f13.yahoofs.com/bc/4640561dm9 ... JBcePgJeED
Here is the working code:
Code: Select all
<?php
$arr = array
('20MICRONS.NS','3IINFOTEC.NS','3MINDIA.NS','AARTIDRUG.NS','AARTIIND.NS','ABAN.NS','ABB.NS');
$url= "http://in.finance.yahoo.com/d/quotes.csv?s=".implode("+",$arr)."&f="."sl1c1p2ohgpvjk";
echo "<table>";
echo "<b><th>Symbol</th> <th>Market Price</th> <th>Change</th> <th>Change %</th> <th>Open</th> <th>High</th> <th>Low</th> <th>Previous Close</th> <th>Volume</th> <th>52 Week Low</th> <th>52 Week High</th></b>";
$handle = fopen($url, "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
echo "<tr>";
foreach($data as $d)
echo "<td>$d</td>";
echo "</tr>";
}
fclose($handle);
echo "</table>";
?>Code: Select all
<?php
$fo=fopen("symbols.txt","r");
while ($line = fgets($fo)) {
$arr[] = $line;
if (count($arr) >= 50) {
$url= "http://in.finance.yahoo.com/d/quotes.csv?s=".implode("+", $arr)."&f="."sl1c1p2ohgpvjk";
echo "<table>";
echo "<b><th>Symbol</th> <th>Market Price</th> <th>Change</th> <th>Change %</th> <th>Open</th> <th>High</th> <th>Low</th> <th>Previous Close</th> <th>Volume</th> <th>52 Week Low</th> <th>52 Week High</th></b>";
$handle = fopen($url, "r");
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
echo "<tr>";
foreach($data as $d)
echo "<td>$d</td>";
echo "</tr>";
}
fclose($handle);
echo "</table>";
$arr = NULL;
}
}
?>1. Unable to get data from the second code. It lists the companies but doesn't get the "sl1c1p2ohgpvjk" data.
2. Creates two different tables for 100 companies whereas I want all data in one table so that an user can sort all of them based on his/her requirement.
3. symbols.txt file actually has 106 symbols. It pulls data for first 100 and the last 6 are ignored. How can I get them to show up on the table?
Thank you