sunnysideup Posted May 27, 2009 Share Posted May 27, 2009 Dear All, I'm trying to parse yahoo quotes using their csv service, everything is runing well, but i cant get to load an image dynamically, my code (without image link) is as follows: <?php $quote = $_GET['company']; $url = "http://in.finance.yahoo.com/d/quotes.csv?s=" . $quote . "&f=sl1d1t1c1ohgvwmj5j6k4k5t7m3m7m8m4m5m6npbaa5a2kj&e=.csv"; //open it for reading $fp = fopen($url , "r"); //if no connection exists display error message if (!fp) { echo "could not connect to the site"; }else { //store the csv file info in the array $data $data = fgetcsv($fp,1000,","); //close the file fclose($fp); ?> <table> <tr><td colspan="2">CHART IMAGE FROM http://ichart.finance.yahoo.com/b?s=GOOG</td></tr> <tr><td>Last Trade</td><td><?php echo $data[1] ?></td></tr> <tr><td>date</td><td><?php echo $data[2] ?></td></tr> <tr><td>time</td><td><?php echo $data[3] ?></td></tr> <tr><td>change</td><td><?php echo $data[4] ?></td></tr> <tr><td>open</td><td><?php echo $data[5] ?></td></tr> <tr><td>high</td><td><?php echo $data[6] ?></td></tr> <tr><td>low</td><td><?php echo $data[7] ?></td></tr> <tr><td>Volume</td><td><?php echo $data[8] ?></td></tr> <tr><td>52 Week Range</td><td><?php echo $data[9] ?></td></tr> <tr><td>Days Range</td><td><?php echo $data[10] ?></td></tr> <tr><td>Change From 52-wk Low</td><td><?php echo $data[11] ?></td></tr> <tr><td>% Chg From 52-wk Low</td><td><?php echo $data[12] ?></td></tr> <tr><td>Change From 52-wk High</td><td><?php echo $data[13] ?></td></tr> <tr><td>% Change From 52-wk High</td><td><?php echo $data[14] ?></td></tr> <tr><td>Ticker Trend</td><td><?php echo $data[15] ?></td></tr> <tr><td>50-day Moving Avg</td><td><?php echo $data[16] ?></td></tr> <tr><td>Change From 50-day Moving Avg</td><td><?php echo $data[17] ?></td></tr> <tr><td>Pct Chg From 50-day Moving Avg</td><td><?php echo $data[18] ?></td></tr> <tr><td>200-day Moving Avg</td><td><?php echo $data[19] ?></td></tr> <tr><td>Change From 200-day Moving Avg</td><td><?php echo $data[20] ?></td></tr> <tr><td>Pct Chg From 200-day Moving Avg</td><td><?php echo $data[21] ?></td></tr> <tr><td>eg..</td><td><?php echo $data[22] ?></td></tr> <tr><td>Previous Close</td><td><?php echo $data[23] ?></td></tr> <tr><td>Bid</td><td><?php echo $data[24] ?></td></tr> <tr><td>Ask</td><td><?php echo $data[25] ?></td></tr> <tr><td>Ask Size</td><td><?php echo $data[26] ?></td></tr> <tr><td>Average Daily Volume</td><td><?php echo $data[27] ?></td></tr> <tr><td>52week High</td><td><?php echo $data[28] ?></td></tr> <tr><td>52 Week Low</td><td><?php echo $data[29] ?></td></tr> </table> <?php } ?> Now i want to include chart image from http://ichart.finance.yahoo.com/b?s=GOOG ??? (Please see line 19 in the above code) Wherin "GOOG" should be loaded from "$quote = $_GET['company'] Can anyone please help. regards Quote Link to comment Share on other sites More sharing options...
sunnysideup Posted May 28, 2009 Author Share Posted May 28, 2009 Can any guru please take a look and advise. regards Quote Link to comment Share on other sites More sharing options...
redarrow Posted May 28, 2009 Share Posted May 28, 2009 i thort that curl would do this, snd scrape the page with regex. Quote Link to comment Share on other sites More sharing options...
sunnysideup Posted May 28, 2009 Author Share Posted May 28, 2009 Dear Redarrow, I'm a complete newbie to php, i do undertsand logic, so if you can please guide me which code to insert where it would help me a lot. regards Quote Link to comment Share on other sites More sharing options...
akitchin Posted May 28, 2009 Share Posted May 28, 2009 feel free to ignore redarrow. since the output of that yahoo charts service is an image, you should be able to put it directly in the image's source attribute, like so: <img src="http://ichart.finance.yahoo.com/b?s=<?php echo $_GET['company']; ?>" alt="<?php echo $_GET['company']; ?> Trading Chart" /> if the charts are always fixed dimensions, you should toss those into the image tag for good measure. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.