Online graph in website

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rrn
Forum Commoner
Posts: 46
Joined: Wed Apr 15, 2009 7:54 am

Online graph in website

Post by rrn »

hi all ,

in my website there is a graph showing some values . that graph is taken from some other site named http://www.xxxx.com

graph is displayed . but the problem is that. whenever the graph changes in the http://www.xxxx.com , the change should also reflect in my website.

change is reflected but only after 3 , 4 hours after the graph changes in http://www.xxxx.com.

the change should be reflected at once , how is it possible?
below shown is the code for updating the graph

Code: Select all

<? php
$ch = curl_init("http://www.xxxx.com");
$fp = fopen("location where it is saved", "w");
 
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
 
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>


please give a solution..thanks..
User avatar
jazz090
Forum Contributor
Posts: 176
Joined: Sun Apr 12, 2009 3:29 pm
Location: England

Re: Online graph in website

Post by jazz090 »

instead of using curl, trying capturing the data using a cron every hour or so into a mysqldb or sqlite, then simple access that data when u need it.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Online graph in website

Post by pickle »

why not just reference the graph directly using an <img> tag?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply