RE: [PHP] How to do a dynamic UPDATE SET

From: Date: Mon, 01 Oct 2001 21:48:06 +0000
Subject: RE: [PHP] How to do a dynamic UPDATE SET
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-69495@lists.php.net to get a copy of this message
| But here's what I want to do now: I want to use the same two | lines of code for any possible form data that might be submitted mysql_list_fields retrieves all field names of $table; with that you can build your SET-clause for the query. something like: $fields = mysql_list_fields($db, $tbl); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $fld = mysql_field_name($fields, $i); $set .= "$fld='$".$fld."', "; } btw: mysql_query("UPDATE ..."); works and saves a line of code. Vincent

« previous php.general (#69495) next »