ok here is what I came up with:
How's this?
function HistoricalStock($sym) {
$row = 1;
$Data =
fopen("http://table.finance.yahoo.com/table.csv?a=7&b=1&c=2002&d=7&e=17&f=20
02&s=$sym&y=0&g=d&ignore=.csv","r");
print '<table width="100%" border="0" cellspacing="1" cellpadding="0"
bgcolor="#6699cc"><tr bgcolor="#FFFFFF">';
while ($Line = fgetcsv ($Data, 1000, ",")) {
if($row == 1) {
echo "<tr bgcolor=\"#FFFFFF\"> <td><b>$Line[0]</b></td>
<td><b>$Line[1]</b></td> <td><b>$Line[2]</b></td>
<td><b>$Line[3]</b></td> <td><b>$Line[4]</b></td>
<td><b>$Line[5]</b></td></tr>";
}
else {
echo "<tr bgcolor=\"#FFFFFF\"> <td>$Line[0]</td> <td>Line[1]</td>
<td>$Line[2]</td>
<td>$Line[3]</td> <td>$Line[4]</td> <td>$Line[5]</td></tr>";
}
$row++;
}
print '</table>';
fclose($Data);
}
"Analysis & Solutions" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Thu, Jul 18, 2002 at 10:14:25AM -0400, Chris Crane wrote:
>
> > Warning: Undefined offset: 5 in
>
> Means your array doesn't have that key in it. I bet you're running into
> blank lines in your file.
>
>
> > $Results = implode('', file("$LookupURL"));
> > $Data = explode("\n", $Results);
>
> Uh, you do realize that you're flip flopping the data around here for no
> reason. file() already creates an array. But you go through the
> unnecessary steps of compressing that array into a string and then
> recreating a new array. Just do this:
>
> $Data = file($LookupURL);
>
> That will eliminate your errors by not adding extra blank lines.
>
>
> > foreach($Data as $Line) {
> > list($H_Date, $H_Open, $H_High, $H_Low, $H_Close, $H_Volume) =
split(",",
> > $Line);
> > print "<tr bgcolor=\"#FFFFFF\">
> >
<td>$H_Date</td>\n<td>$H_Open</td>\n<td>$H_High</td>\n<td>$H_Low</td>\n<td>$
> > H_Close</td>\n<td>$H_Volume</td>\n</tr>";
> > }
>
> But, your whole approach is wasteful. As I said yesterday, use fopen()
> and then fgetcsv(). Forget the file() and split() calls.
>
> Then, you're wasting time and memory with the list(). Use the resulting
> array directly.
>
> while ( $Line = fgetcsv($fp, 500) ) {
> echo "<tr> <td>$Line[0]</td> <td>$Line[1]</td> ... etc ...";
> }
>
> Or, since you're pringing everything out, you could just do this:
>
> while ( $Line = fgetcsv($fp, 500) ) {
> echo '<tr><td>' . implode('</td><td>', $Line) . '</td></tr>'
> }
>
> --Dan
>
> --
> PHP classes that make web design easier
> SQL Solution | Layout Solution | Form Solution
> sqlsolution.info | layoutsolution.info | formsolution.info
> T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
> 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php