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:[EMAIL PROTECTED]]
> Sent: 21 February 2001 20:17
> To: 'Mike'; [EMAIL PROTECTED]
> 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:[EMAIL PROTECTED]]
> Sent: Wednesday, February 21, 2001 11:34 AM
> To: [EMAIL PROTECTED]
> 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
> [EMAIL PROTECTED]
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: 
> [EMAIL PROTECTED]
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to