I am searching the db for, in this case cpu's and grouping them by cpu type.
The code is fine for most queries but some have a quantity in the order as well. If q is more than 1 i need it to take that into account.
Current code is:
Code: Select all
$cpu = "SELECT count(cpu) as amount,cpu,q FROM orders WHERE status='Processing' GROUP BY cpu";
$cpuq = mysql_query($cpu, $db_conn) or die("Query $cpu failed".mysql_error());
while ($cpurow = mysql_fetch_array($cpuq))
{
if ($cpurow['q']>1)
{
$needed = $cpurow['amount']*$cpurow['q'];
}
else
{
$needed = $cpurow['amount'];
}Example:
If i had the following in the orders table
Code: Select all
cpu Quantity
cpu1 1
cpu1 5
cpu2 5Where as :
Code: Select all
cpu Quantity
cpu1 1
cpu2 5feyd | Please review how to post code using
Code: Select all
andCode: Select all
tags. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]