note 37782 added to function.implode
| From: | daevid at daevid dot com | Date: | Thu, 27 Nov 2003 01:07:05 +0000 |
| Subject: | note 37782 added to function.implode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-61010@lists.php.net to get a copy of this message | ||
I can't take credit for this, but it is a true life saver for creating an update in a loop
structure...
while(list($column, $value) = each($FOO))
{
$upd[] = " $column = '$value'"; //this will loop until sql is built
}
$SQL = "UPDATE table set ".implode(',',$upd)." Where blah = 3 LIMIT
5"; //now do it
$result = mysql_query($SQL,$db);
----
Manual Page -- http://www.php.net/manual/en/function.implode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37782
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37782&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37782&report=yes
Search -- http://master.php.net/manage/user-notes.php