I am currently working on some different things with the old KShop module and one thing that I am working on is adding jpgraphs to the module.
I am not an expert with PHP but I can hack my way through it. one thing I am trying to do is build a function to query how much of each product is sold and put it into an array to be used with jpgraph
It would be great if someone could help guide me in the right direction.
There is a table in the datablase where KShop writes how much of each product is sold and this is where I want to pull the data from.
here is some raw output from the .sql file for that table
(`id`, `order_id`, `qty`, `p_num`, `p_name`, `p_price`) VALUES (1, 1, 3, 'A01', 'Apples Option: Braeburn', '12.00')
Now what I am trying to do is build a function that will query the qty (quantity) of each item ordered.
for example the array would have the following
25 apples
100 oranges
30 cookies
ect..
The values that I want to put into jpgraph is the following
total amount of each product sold
the name of each product to associate with the amount
I figured I will need to query the colums qty, p_num, p_name
here is a copy of the code I have so far. I know this does not return what I want but I was hopeing that someone could help me fix it.
function loadstats(){
global $xoopsDB,$xoopsModuleConfig;
$stat=array();
$query = $xoopsDB->query(' SELECT * FROM ' . $xoopsDB->prefix('kshop_orders_products'));
while ($row = $xoopsDB->fetchArray($query))
{
$stat['qty']=$row['qty'];
$stat['p_num']=$row['p_num'];
$stat['p_name']=$row['p_name'];
}
return $stat;
}
Thanks!