Weird query and display issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,
 
First off.. a many thanks to those to helped me with my previous issue.
I'll email the working solution under separate email.
 
The following code is displaying 3 results when it SHOULD only be
displaying 1 result (I know it should be one because only one product
was selected to be ordered).
 
$query = "SELECT * FROM CartTable WHERE cart_id='$ID' AND
company='$company' AND (product_index='1' OR product_index='2' OR
product_index='3')";
            $result = mysql_query($query);
 
            while($cartResult = mysql_fetch_array($result)) {
 
                        $allrows[] = $cartResult;
 
                        if ($cartResult[name] == "Baseball Hitting Aid"
|| $cartResult[name] == "Tennis Training Aid") {
 
                                    $quantity += $cartResult[quantity];
                                    $name = "Practice Hit";
 
                        }
 
                        if ($cartResult[name] == "Golf Swing Trainer") {
 
                                    $quantity = $cartResult[quantity];
                                    $name = "Swing Lock";
 
                        }
 
                        
            }
                        
                                                
            foreach($allrows as $cartResult) {
 
                        echo $quantity." ".$name;
 
            }
 
Would anyone happen to know where my problem is?
 
What I am trying to do is if any products in the shopping cart are the
"Baseball Hitting Aid" OR "Tennis Training Aid".. group those together
under one name (Practice Hit) and add up the total quantity of both.
 
If any products in the shopping cart are the "Golf Swing Trainer"..
rename to "Swing Lock" and use the quantity specified.
 
Any thoughts?
 
Thanks!
 
Aaron
 

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux