Nope, still no go.  Removing the single quotes stops PHP from updating the
fields with $set's literal "$fieldname", but still doesn't update the record
with the value (or anything).

===============
CODE
===============
if ($submit) {
// if there is an ID, then it's an update
  if ($id) {
          $comma = "";
        for ($i = 1; $i < $columns; $i++) {
          $fld = mysql_field_name($fields, $i);
          $set .= $comma."$fld=$".$fld;
          $comma = ", ";
          }
          $set .= " ";

  echo $set, "<p>";

  // run SQL against the DB
  $sql = "UPDATE events SET what=$what WHERE id=$id";
  echo $sql, "<p>";
  $result = mysql_query($sql);
   }
   echo "<span class=adminnormal>Record updated";
}
===============
OUTPUT
===============
lang=$lang, record=$record, date=$date, what=$what, link=$link,
location=$location, details=$details

UPDATE events SET lang=$lang, record=$record, date=$date, what=$what,
link=$link, location=$location, details=$details WHERE id=1

Record updated
===============


...Rene

---
Rene Fournier
[EMAIL PROTECTED]

> -----Original Message-----
> From: Vincent [mailto:[EMAIL PROTECTED]]
> Sent: Monday, October 01, 2001 5:49 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] 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, sorry.
> I think removing the single quotes should do the trick.
>
> Vincent
>
>
> --
> 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