Hi there -
I figured out how to put my data into a JSON format using PHP and MySQL, see below. Now, could someone please help me create, say, a pie chart with Google Charts. I have not done this before, and I could use some help creating it.
<?php
// Connect to MySQL
include ("./mylibrary/login.php");
login();
// Fetch the data
$query = "
SELECT priority, COUNT(*) AS num_count\n"
. " FROM issue\n"
. " GROUP BY priority ";
$result = mysql_query( $query );
// All good?
if ( !$result ) {
// Nope
$message = 'Invalid query: ' . mysql_error() . "\n";
$message .= 'Whole query: ' . $query;
die( $message );
}
// Print out rows
$prefix = '';
echo "[\n";
while ( $row = mysql_fetch_assoc( $result ) ) {
echo $prefix . " {\n";
echo ' "priority": "' . $row['priority'] . '",' . "\n";
echo ' "num_count": ' . $row['num_count'] . "\n";
echo " }";
$prefix = ",\n";
}
echo "\n]";
?>
Thank you,
Hugo