Fill in a chart with data from a vector

1

I'm new here and this is my first question, I'm starting in PHP and wanted to know how I can fill a CHART with variables received by an array.

My code sample is as follows:

<?php
$datacomp = date('d/m/y');
$consulta=mysql_query("SELECT SOBRECONSUMO_DIA, DATA_I FROM 'atividades' WHERE SOBRECONSUMO = 1 and SOBRECONSUMO_DIA <> NULL");
$numrows=mysql_num_rows($consulta);
do {
        $valor[$x]=$rows['SOBRECONSUMO_DIA'];
        $data[$x]=$rows['DATA_I'];
        echo "<script type=\"text/javascript\"> var x = '"$x"'var valor[x]='".$valor[$x]"' var data[x]='".$data[$x]"'}</script>";
} while ($rows= mysql_fetch_array($consulta))

And the JS code that will run after the above is this:

$(function () {
    for (var i; x=i;i++)
    {
    Morris.Area({
        element: 'morris-area-chart',
        data: [{
            period: data[x],
            valor de consumo: valor[x],
        }
]})

I know it's wrong, but I need to know a way to run this loop to throw the data into the Chart. VALEU!

    
asked by anonymous 30.06.2016 / 16:24

0 answers