RE: [PHP] Tough one?

From: Date: Wed, 21 Feb 2001 20:17:23 +0000
Subject: RE: [PHP] Tough one?
Groups: php.general 
Request: Send a blank email to php-general+get-41059@lists.php.net to get a copy of this message
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[$keys[$x]]."',"; } $x++; $updateString=$updateString.$keys[$x]."='".$HTTP_POST_VARS[$keys[$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[$keys[$x]]."',"; } else { $updateString=$updateString.$keys[$x]."='".$HTTP_POST_VARS[$keys[$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[$keys[$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

« previous php.general (#41059) next »