I have problem with getting data from SQL Database to a dynamic Chart in PHPExcel
SQL code
` $qry = "SELECT * FROM t_category
ORDER BY id_category";
$sql = mysql_query($qry);
while ($showcategory= mysql_fetch_array($sql)) {
$id_category = $showcategory['id_category'];
$name_category = $showcategory['name_category'];
$qry2 = "SELECT SUM(stock) AS total_stok FROM t_product WHERE id_category ='$id_category'";
$sql2= mysql_query($qry2);
$datastock = mysql_fetch_array($sql2);
echo $showcategory['name_category']." :".$datastock ['total_stok']."<br/>";
}`
Which gives output as follows :
product1 : 20
product2 : 30
product3 : 10
And So On..
The Question is how to make these SQL output become dynamic array that would be Implemented on PHPExcel like this
$objWorksheet->fromArray(
array(
array('', Product 1, Product2, Product3, And So On...),
array('Stock', 20, 30, 10, And So On...),
)
);