RE: [PHP] multiple foreach
| From: | Richard Whitney | Date: | Fri, 21 Mar 2003 02:53:52 +0000 |
| Subject: | RE: [PHP] multiple foreach | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-140530@lists.php.net to get a copy of this message | ||
Thank you, Martin - you're a certifiable genius!
It's just that $size needed to be $size_id - I fixed that, though.
Thanks!
Richard
Quoting Martin Towell <martin.towell@world.net>:
### 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
###
### --
### PHP General Mailing List (http://www.php.net/)
### To unsubscribe, visit: http://www.php.net/unsub.php
###
###
--
Richard Whitney *
Transcend Development
Producing the next phase of your internet presence.
rw@xend.net *
http://xend.net *
602-971-2791
* * *
* * *__ * *
_/ \___ *
* / * \* *
*/ * * \
* */\_ |\
/ \_ / \
/ \____/ \
/ \
/ \
/ \