ORDERID NAME QTY
100 BOOK 2
100 PEN 3
101 BOOK 8
102 PEN 2
102 GLASS 3
102 PEN 1
And i want php to count the product quantity like this :
BOOK = 10
PEN = 6
GLASS = 3
I use this code, but it's not working can someone spare your time and help me figure it out, I'm stuck.
$qLocation1 = "SELECT DISTINCT `name` FROM mydata";
$RS_Location1 = mysql_query($qLocation1);
while ($TS = mysql_fetch_array($RS_Location1)) {
$total_qty = 0;
$qcountnow = "SELECT * FROM mydata where product_code='TS[name]'";
$RS_countnow = mysql_query($qcountnow);
while ($RS = mysql_fetch_array($RS_countnow)) {
$total_qty = $RS[product_qty] + $total_qty;
} // while ($RS = mysql_fetch_array($RS_countnow)) {
echo "$TS[product_code] - $total_qty <br>";
$total_qty = 0;
} // END OF while ($TS = mysql_fetch_array($RS_Location1))