javascript - How to set any jQuery chart data with PHP -


i'm using template jquery charts enter image description here 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

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -