Weird query and display issue

From: Date: Thu, 08 May 2003 00:50:23 +0000
Subject: Weird query and display issue
Groups: php.db 
Request: Send a blank email to php-db+get-27573@lists.php.net to get a copy of this message
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

« previous php.db (#27573) next »