PHP回显Javascript变量以动态更改饼图图表
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; ?>]);
我有以下代码。 请查看 jsfiddle页面。 在这段代码中有静态数字,5和10.这些需要更改为动态数字,由PHP代码在变量 我已经尝试了很多东西,请参阅jsfiddle页面。 p>
所以基本上如何在下面的例子中用PHP代码替换5和10? p>
解决方案 感谢Jeff Shaver在Clamidity的帮助下: p>
$ result1 code>和
$ result2 code>中生成。 p >
var pie = new RGraph.Pie('cvs',[result1,10]);
code> pre>
var pie = new RGraph.Pie('cvs',[&lt;?php echo $ result1;?&gt;,&lt; ?php echo $ result2;?&gt;]);
code> pre>
div>
You have to echo them in.
var pie = new RGraph.Pie('cvs', [<?php echo $result1; ?>,10]);