I'm having a REALLY hard time with something that's probably easy to do (for
someone :-)...
Normally, to perform an update on a table with data from a submitted form, I
would use something like:
$sql = UPDATE $table SET pet='$pet', name='$name' WHERE id=$id;
$result = mysql_query($sql);
| 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 =
];
$comma = ,;
}
$sql = UPDATE $table $set_clause WHERE id=$id;
-Joe
-Original Message-
From: René Fournier [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 01, 2001 2:33 PM
To: [EMAIL PROTECTED]
Subject: [PHP] How to do a dynamic UPDATE SET
I'm having a REALLY hard time with something
| The result: PHP updates the values of lang, record, date, what (etc.) to
| [LITERALLY] $lang, $record, $date, etc--NOT the values of those fields
| submitted by the form. I'm kinda lost as to what to do... Any
| suggestions??
Ow yea, little mistake of mine, sorry.
I think removing the
] How to do a dynamic UPDATE SET
| The result: PHP updates the values of lang, record, date, what
(etc.) to
| [LITERALLY] $lang, $record, $date, etc--NOT the values of those fields
| submitted by the form. I'm kinda lost as to what to do... Any
| suggestions??
Ow yea, little mistake of mine
5 matches
Mail list logo