RE: Weird query and display issue

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

 



Hi All,

Got this working with help from another over at devshed.com

$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)) {

        if ($cartResult["name"] == "Baseball Hitting Aid" ||
$cartResult[name] == "Tennis Training Aid") {

            $products["Practice Hit"]+=$cartResult["quantity"];

        }

        if ($cartResult["name"] == "Golf Swing Trainer") {

            $products["Swing Lock"]+=$cartResult["quantity"];
        }

        
    }
        
                
    foreach($products as $product => $quantity) {

        echo $quantity." ".$product;

    }


Thanks for all who took the time to provide insight.

Aaron

-----Original Message-----
From: Matt King [mailto:php@magnetinternet.com] 
Sent: May 7, 2003 11:52 PM
To: php-db@lists.php.net
Subject: Re:  Weird query and display issue

Aaron Wolski wrote:
> 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).

Are you sure there aren't isn't than one result? What does
mysql_num_rows($result) return?

>                         $allrows[] = $cartResult;

This doesn't  make any sense to me...why are you doing this?  Then you
are
iterating through it at the bottom.  So if there are 3 things printing,
there must be 3 things in this array...check your rows returned.

-- 
Matt King
magnet | internet
http://www.magnetinternet.com

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

  Powered by Linux