It's been awhile, hello everyone. I'm stumped on something basic here.
I have a table called orders, which lists all the orders I've had on my online store. I'd like to create a table that looks like this:
Product Quantity Sold
CPQ1000 3
Dell1000 2
and so forth. The field name for product is ItemNumber. So here is my sql so far, and all it does is return ItemNumber the number of times it appears in the table, which ain't right. The query starts when the user selects a value named 'AllProducts', which should total the sale of each product sold, and then create the list like above:
<?
include("dbconnect.php");
$query = "select * from orders order by itemNumber"; //where prod_name is the product name
$result = mysql_query($query, $mysql_link);
$products = "";
while($row = mysql_fetch_row($result))
{
if($product == $row[2]){}
else{
echo $row[2]."<br>";
$product = $row[2];
}
}
?>
Thanks in advace!!