Thursday, 8 August 2013

Undefined index error [on hold]

Undefined index error [on hold]

This is my query. Im getting only first record in remaining records no of
product and total value are not displaying. It is showing 0 only.
$str="SELECT s.`customer_email`,e.`value` as type
FROM `catalog_product_entity_int` c join `sales_flat_order_item` p on
c.`entity_id`=p.`product_id` join `sales_flat_order` s on
p.`order_id`=s.`entity_id` join `eav_attribute_option_value` e on
e.`option_id`=c.`value` where c.`attribute_id`=143 and e.`value`!='Gold
coin' and e.`store_id`=0 limit 5";
$rs=mysql_query($str);
echo "<table border='1'>
<tr>
<th>Customer Name</th>
<th>Product type</th>
<th>no of product</th>
<th>total value</th>
</tr>";
while($ds=mysql_fetch_assoc($rs))
{
$var="SELECT count(*) as no_of_purchase,sum(p.price) as total FROM
`sales_flat_order_item` p join `catalog_product_entity` cp on
p.`sku`=cp.`sku` join `catalog_product_entity_decimal` d on
cp.`entity_id`=d.`entity_id` join `sales_flat_order` s on
s.`entity_id`=p.`order_id` where
customer_email='{$ds['customer_email']}' and value='{$ds['value']}' ";
$result=mysql_query($var) or die(mysql_error());
while($row=mysql_fetch_assoc($result)){
echo "<tr>";
echo "<td>" . $ds['customer_email'] . "</td>";
echo "<td>" . $ds['type'] . "</td>";
echo "<td>" . $row['no_of_purchase'] . "</td>";
echo "<td>" . $row['total'] . "</td>";
echo "</tr>";
}
}
echo "</table>";
I need the output in this following for all customers:
Customer Name Product type no of product total value
abc@gmail.com Rings 6 6864.0000
Can anybody help?? but Im getting wrong results in this

No comments:

Post a Comment