note 16464 added to function.each
| From: | jamesmc at jamesmc dot org | Date: | Thu, 01 Nov 2001 00:08:04 +0000 |
| Subject: | note 16464 added to function.each | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19940@lists.php.net to get a copy of this message | ||
I was faced with typing out an SQL UPDATE statement that would have over 100 fields to update...
Thanks to the each() function, It saved me stacks of time!
Here is my update function now, based on the $HTTP_POST_VARS example near the top.
reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
$sql = "UPDATE product SET $key='$val' WHERE prod_id='$prod_id';
$qu = mysql_query($sql) or die(mysql_error());
}
--
http://www.php.net/manual/en/function.each.php
http://master.php.net/manage/user-notes.php?action=edit+16464
http://master.php.net/manage/user-notes.php?action=delete+16464
http://master.php.net/manage/user-notes.php?action=reject+16464