I'm not all that familiar with MySQL and PHP, but what you ultimately need
to do is query the database as described
here<http://stackoverflow.com/questions/5157905/mysql-query-result-in-php-variable>,
then put the output into a JS 2D array, and then use that array in your
JavaScript code to chart it. I'd imagine your code will look something like
the following:

var data = new google.visualization.arrayToDataTable([
<?php
$result = mysql_query("SELECT date, data FROM table");
$firstRow = TRUE;
while ($row = mysql_fetch_array($result)) {
  if (!$firstRow) {
    echo ",\n";
  }
  echo "[";
  echo date("new Date(Y, m, d)", $row[0]); /* Or however you format the
date to get it to the JS format */
  echo ", ";
  echo row[1];
  echo "]";

  $firstRow = FALSE;
}
?>
]);

function drawVisualization() {
  var chart = new
google.visualization.LineChart(document.getElementById("visualization"));
  chart.draw(data, {});
}

- Sergey


On Thu, Feb 28, 2013 at 6:20 PM, Vojtěch Piska <[email protected]> wrote:

> Hi friends
>
> I have problem in mySQL DB have  id, data (number), date(timestamp)...I
> would like to display on X-axis the date(timestamp) and on Y-axis
> propriate data (number). But I dont know how to gain this information
> from DB to Chart script :/
>
> Thank you a lot!:)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Chart API" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/google-chart-api?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Chart API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-chart-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to