Here is the problem
$rd = do_mysql_query("SELECT sum(product_price * '{$count}') as letsee
FROM prices
WHERE product_id = '{$record['prodid']}'
AND id='{$id_p}'
ORDER BY product_id") or sqlerr(__FILE__, __LINE__);
while($row = mysqli_fetch_array($rd)){
echo "{$record['prodid']}:{$row['letsee']}<br />"; //id:count
}
its out for me
10:130
10:95
7:88
6:35
6:120
6:330
11:104
11:64
i need to Plus all counts by id
needed result
thanks
You can do it with php:
foreach($records as $record){//First loop or something like it
$rd = do_mysql_query("SELECT sum(product_price * '{$count}') as letsee FROM prices WHERE product_id = '{$record['prodid']}' AND id='{$id_p}' ORDER BY product_id") or sqlerr(__FILE__, __LINE__);
while($row = mysqli_fetch_array($rd)){
$final_array[$record['prodid']]+=$row['letsee']; //id:count
}
}//End of First loop or something like it
foreach($final_array as $key => $value){
echo $key.':'.$value;
}
Note: I think you should use php, because checking your code it seems, you have another loop to get $record['prodid']
and $count
which is causing the duplicates. This can't be solved with the query if you're sending the same product_id more than once.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments