RE: [PHP] Tough one?
| From: | Tim Ward | Date: | Thu, 22 Feb 2001 09:19:14 +0000 |
| Subject: | RE: [PHP] Tough one? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-41111@lists.php.net to get a copy of this message | ||
a quite neat (though maybe no more efficient) way would be ...
$keys = array_keys($HTTP_POST_VARS);
$key_list = array();
foreach($keys as $fred)
{ $key_list() = $fred."='".$HTTP_POST_VARS[$fred]."'";
}
$updateString=$updateString.implode(",", $key_list)."'";
... I haven't tested the detail of this but the theory is sound, I'm fairly
sure.
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: Shawn Esplin [mailto:sesplin@cleanup.org]
> Sent: 21 February 2001 20:17
> To: 'Mike'; php-general@lists.php.net
> Subject: RE: [PHP] Tough one?
>
>
> I'm not sure this is the best way to do it, but you could try:
>
> $keys = array_keys($HTTP_POST_VARS);
> for($x = 2; $x < (count($keys) - 1); $x++)
> {
>
> $updateString=$updateString.$keys[$x]."='".$HTTP_POST_VARS[$ke
> ys[$x]]."',";
> }
> $x++;
> $updateString=$updateString.$keys[$x]."='".$HTTP_POST_VARS[$ke
> ys[$x]]."'";
>
> or:
>
> $keys = array_keys($HTTP_POST_VARS);
> for($x = 2; $x < count($keys); $x++)
> {
> if($x != (count($keys) - 1))
> {
>
> $updateString=$updateString.$keys[$x]."='".$HTTP_POST_VARS[$ke
> ys[$x]]."',";
> }
> else
> {
>
> $updateString=$updateString.$keys[$x]."='".$HTTP_POST_VARS[$ke
> ys[$x]]."'";
> }
> }
>
> -----Original Message-----
> From: Mike [mailto:mpeloso@princeton.edu]
> Sent: Wednesday, February 21, 2001 11:34 AM
> To: php-general@lists.php.net
> Subject: [PHP] Tough one?
>
>
> I am building an update string on the fly from form fields.I
> am trying to
> add a comma between fields but I cant have one after the last
> field.This is
> the code that doesnt work.Also I cant have a comma at all in
> a table with
> only one updated field.
>
> $keys = array_keys($HTTP_POST_VARS);
> for($x = 2; $x < count($keys); $x++)
> {
> $updateString=$updateString.$keys[$x]."='".$HTTP_POST_VARS[$ke
> ys[$x]]."',";
>
> Thanks
> Mike
> mpeloso@princeton.edu
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>