Hello:
I'm totally new to PHP. I'm trying to generate a bunch of graphs dynamically and I downloaded this free PHP script which looks fine. But my requirement is to dynamically update the numbers in the PHP array. Please see below.
$data1['Total Run Time'] = 800;
$data1['Down Time'] = 219;
$data1['Actual Run Time'] = 500;
$mc1 = new maxChart($data1);
$mc1->displayChart('Operating Rate - Stage 1',0,500,150,true);
echo " <br/>";
.
.
.
$data['6a'] = 9.9;
$data['7a'] = 19.9;
$data['8a'] = 29.9;
$data['9a'] = 69.9;
I don't have any databases configured. I do have an UNIX script which can pull the updated information i.e., total run time, downtime etc.. Now, is there a way I could dynamically update those numbers in to the PHP script.
Please advice.
Updating PHP script
Moderator: General Moderators
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Updating PHP script
Update which numbers? What does the output of the Unix script look like?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Updating PHP script
The output of UNIX script looks like this,
Stage=1
Total Time: 237.5 mins
Run Time : 95.2 mins
Down Time : 142.3 mins
Estimated # of boards : 84 @ 55.19 % Operating Rate
Actual # boards Produced : 91 @ 40.0 % Operating Rate
Estimated Average Cycle time per board: 67.60020 secs
Actual Average Cycle time per Board : 60.0 secs
Stage=2
Total Time: 236.7 mins
Run Time : 155.2 mins
Down Time : 81.5 mins
Estimated # of boards : 140 @ 53.62 % Operating Rate
Actual # boards Produced : 89 @ 60.0 % Operating Rate
Estimated Average Cycle time per board: 66.180 secs
Actual Average Cycle time per Board : 102.0 secs
My requirement is to take the numbers highlighted in bold abd populate them in the PHP code..
$data1['Total Run Time'] = 800;
$data1['Down Time'] = 219;
$data1['Actual Run Time'] = 500;
Thank you
Stage=1
Total Time: 237.5 mins
Run Time : 95.2 mins
Down Time : 142.3 mins
Estimated # of boards : 84 @ 55.19 % Operating Rate
Actual # boards Produced : 91 @ 40.0 % Operating Rate
Estimated Average Cycle time per board: 67.60020 secs
Actual Average Cycle time per Board : 60.0 secs
Stage=2
Total Time: 236.7 mins
Run Time : 155.2 mins
Down Time : 81.5 mins
Estimated # of boards : 140 @ 53.62 % Operating Rate
Actual # boards Produced : 89 @ 60.0 % Operating Rate
Estimated Average Cycle time per board: 66.180 secs
Actual Average Cycle time per Board : 102.0 secs
My requirement is to take the numbers highlighted in bold abd populate them in the PHP code..
$data1['Total Run Time'] = 800;
$data1['Down Time'] = 219;
$data1['Actual Run Time'] = 500;
Thank you
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Updating PHP script
Obviously I can't test this, but it should work and/or get you on the right track:
Code: Select all
exec('/path/to/script', $output);
$output = implode(PHP_EOL, $output);
preg_match_all('/Stage[^\d]*([\d\.]+)[^\d]*Total Time[^\d]*([\d\.]+)[^\d]*Run Time[^\d]*([\d\.]+)[^\d]*Down Time[^\d]*([\d\.]+)/', $output, $matches, PREG_SET_ORDER);
foreach($matches as $stage) {
$number = $stage[1];
$data1['Total Run Time'] = $stage[2];
$data1['Actual Run Time'] = $stage[3];
$data1['Down Time'] = $stage[4];
$mc1 = new maxChart($data1);
$mc1->displayChart("Operating Rate - Stage $number", 0, 500, 150, true);
echo " <br/>";
}mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Updating PHP script
Thanks for your help!