I'm using the below code to get some data.
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$data[] = array(
$row['Qty'],
$row['Description']
);
}
This is giving an empty array.
When I'm trying the $sql
manually its getting the correct results.
Is anything wrong with the code above..?
SELECT CO.order_id AS TaxNo,
DATE_FORMAT(CO.created,'%d-%m-%Y') AS InvoiceDate,
C.company_name AS Consumer, CONCAT(C.delivery_address1, ', ',
C.delivery_address2) AS DelAdd,
COD.qty AS Qty,
P.product_name AS Description,
PP.amount AS Price,
(COD.qty * PP.amount) AS Total,
SUM(COD.qty * PP.amount) AS InvoiceTotal,
CPH.discount_on_payment AS Discount,
CPH.amount_paid AS AmountPaid,
(SUM(COD.qty * PP.amount) - CPH.discount_on_payment - CPH.amount_paid) AS Balance,
COUNT(COD.qty) AS TotLine
FROM consumer_orders AS CO
INNER JOIN consumer AS C ON CO.consumer_id = C.consumer_id
INNER JOIN consumer_order_details AS COD ON CO.order_id = COD.order_id
INNER JOIN product AS P ON COD.Product_id = P.product_id
LEFT JOIN product_price AS PP ON P.product_id = PP.product_id
LEFT JOIN tbl_customer_payment_history AS CPH
ON CO.order_id = CPH.order_id WHERE CO.order_id = '60'
GROUP BY CO.order_id, CO.created, C.company_name, CONCAT(C.delivery_address1, ', ', C.delivery_address2), COD.qty, P.product_name, PP.amount