$row2 = mysql_fetch_array($result2);
$row3 = mysql_fetch_array($result3);
$row4 = mysql_fetch_array($result4);
echo $row4;
$row5=10;
?>
<script>
var t = new PieChart({
container: document.getElementById("demo"),
area: { height: 350 },
data: {
preloaded: {
subvalues: [
{ id: "pun", value:x, style: { expandable: false } },
{ id: "tec", value: 20, style: { expandable: false } },
{ id: "hel",value:50,style:{expandable:false}},
{ id: "int",value:10,style:{expandable:false}},
{ id: "stu",value:10,style:{expandable:false}}
]
}
}
});
</script>
如何传递&#34; x&#34;的值用于php.if使用;它没有显示饼图。使用json编码也无法正常工作
答案 0 :(得分:0)
您可以在里面注入PHP代码。
<script>
var t = new PieChart({
container: document.getElementById("demo"),
area: { height: 350 },
data: {
preloaded: {
subvalues: [
{ id: "pun", value: <?php echo (int)$x; ?>, style: { expandable: false } },
{ id: "tec", value: 20, style: { expandable: false } },
{ id: "hel",value:50,style:{expandable:false}},
{ id: "int",value:10,style:{expandable:false}},
{ id: "stu",value:10,style:{expandable:false}}
]
}
}
});
</script>