1

I have the following code. Please look at the jsfiddle page. In this code there are static numbers, 5 and 10. These need to be changed to dynamic numbers, produced by PHP code in variables $result1 and $result2.

I have tried numerous things, see the jsfiddle page please.

So basically how to replace the 5 and 10 with PHP code in the example below?

var pie = new RGraph.Pie('cvs', [result1,10]);

The solution thanks to Jeff Shaver with help from Clamidity:

var pie = new RGraph.Pie('cvs', [<?php echo $result1; ?>,<?php echo $result2; ?>]);

1 Answer 1

1

You have to echo them in.

var pie = new RGraph.Pie('cvs', [<?php echo $result1; ?>,10]);
Sign up to request clarification or add additional context in comments.

5 Comments

Great answer. For the sake of not relying on php shortags I would use <?php echo $result1; ?>
Yes that is the answer brilliant. Thank you very much saved me a lot of time. This will be the accepted answer but i have to wait 11 minutes for that.
Or <?= $result1 ?>, which is (oddly) enabled by turning on short tags, but not deprecated along with short tags.
Just forgot to add the php. I have updated the answer. thanks for pointing that out
Thanks for updating the code Jeff. Clamidity thanks for the php adding part!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.