-1
$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>

how to pass value of "x" in for php.if using; it is not showing pie chart.using json encode is also not working

johnny 5
  • 19,893
  • 50
  • 121
  • 195

1 Answers1

0

You can inject a PHP code inside.

<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>
ksimka
  • 1,394
  • 9
  • 21