I am using jqplot to show data in a graph.I am able to fetch data in the array ,but I have a small problem to plot data the format is
[["Pens",10],["Pencils",30],["Erasers",40],["Charts",3]]
I am getting data in the following format
[["Pens"],["10"],["Pencils"],["30"],["Erasers"],["40"],["Charts"],["3"]]
my code is as follows
PHP Code
$dbname = 'dbname';
$username = 'root';
$password = 'password1!';
try {
/* Establish the database connection */
$conn = new PDO("mysql:host=localhost;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$result = $conn->query("SELECT Compliancestatus,value FROM COUNT_VALUE WHERE Zone='PZ' and country='AU' and `Compliancestatus` is not null");
$jsonTable = json_encode($rows);
print_r($jsonTable);
} catch (PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
//mysql_close($conn);
$conn = null;
$rows = array();
foreach ($result as $r) {
$rows[] = array($r['Compliancestatus']);
// Values of each slice
$rows[] = array($r['value']);
}
please help me in this regard.