MySql Update.

From: Date: Tue, 12 Nov 2002 18:58:24 +0000
Subject: MySql Update.
Groups: php.db 
Request: Send a blank email to php-db+get-23254@lists.php.net to get a copy of this message
Making an update query that adapts to the number of fields that are to be updated Is there anyway to do like a for loop to create the values part of the query then combine it with the first part of the string. something like what i have below... although something that works correctly as this doesn't. ====================================== $table is the table name $num_headers is the number of headers (fieldnames) for that table $table_headers is an array with the names of the headers $values is an array with the names of the input boxes on the previous page ====================================== $query1 = "UPDATE ".$table." SET " ; $query2 = ( for ($x=0; $x <=$num_headers; $x++){
                  ". $table_headers[$x] . "=" . $values[$x] . " , "
                  }) ;
$query = $query1.$query2 ; $result = mysql_query ($query) ; etc... _________________________________________________________________ Help STOP SPAM with the new MSN 8 and get 2 months FREE* http://join.msn.com/?page=features/junkmail

« previous php.db (#23254) next »