RE: [PHP] multiple foreach

From: Date: Fri, 21 Mar 2003 02:47:59 +0000
Subject: RE: [PHP] multiple foreach
Groups: php.general 
Request: Send a blank email to php-general+get-140526@lists.php.net to get a copy of this message
try this... for ($i = 0; $i < count($charge); $i++) { $c = $charge[$i]; $s = $size[$i]; $sql = "UPDATE products_to_sizes SET surcharge = '$c' WHERE product_id = '$products_id' AND size_id = '$s'"; mysql_query($sql) or die ("Couldn't update rows".MYSQL_ERROR()); print $sql.'<br>'; } -----Original Message----- From: Richard Whitney [mailto:rw@xend.net] Sent: Friday, March 21, 2003 1:00 PM To: php-general@lists.php.net Subject: [PHP] multiple foreach Maybe someone can see what I'm trying to do with this: foreach($charge as $c){ foreach($size_id as $s){$sql = "UPDATE products_to_sizes SET surcharge = '$c' WHERE product_id = '$products_id' AND size_id = '$s'"; mysql_query($sql) or die ("Couldn't update rows".MYSQL_ERROR()); print $sql.'<br>';} } I get this: UPDATE products_to_sizes SET surcharge = '1.50' WHERE product_id = '28' AND size_id = '6' UPDATE products_to_sizes SET surcharge = '1.50' WHERE product_id = '28' AND size_id = '7' UPDATE products_to_sizes SET surcharge = '3.00' WHERE product_id = '28' AND size_id = '6' UPDATE products_to_sizes SET surcharge = '3.00' WHERE product_id = '28' AND size_id = '7' I need to get rid of the two middle statements Help!! :-) -- Richard Whitney * Transcend Development Producing the next phase of your internet presence. rw@xend.net * http://xend.net * 602-971-2791 * * * * * *__ * * _/ \___ * * / * \* * */ * * \ * */\_ |\ / \_ / \ / \____/ \ / \ / \ / \ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#140526) next »