javascript - How to set any jQuery chart data with PHP -
i'm using template jquery charts values in these charts being set jquery want fetch own values database , set them instead of these values jquery sets with. know not possible nest php in jquery, should do?
it looks use morris.js library.
i'd suggest echo out javascript part, this:
<?php if($condition){ echo "<script> morris.donut({ element: 'donut', resize: true, data: ["; foreach($value $m){ //your foreach here $value got fetching data database via mysqli or pdo $c = count($value); $amount = $m['amount']; //just example things if($c != 1){ echo "{label: '".$type."', value: $amount"."},"; } else { echo "{label: '".$type."', value: $amount"."}"; } unset($value['0']); } echo" ] }); </script>"; } else { echo "<script> morris.donut({ element: 'donut', resize: true, data: [{label: 'nothing here yet', value: 1}] }); </script>"; } ?>
Comments
Post a Comment