update mysql without manually tying SET statements



I am trying to setup some generic code that will allow me to update a mysql database via form and php. I can capture the data in the row of the database that I want to update. I can present that in a form populated with the existing values. What I can't figure out how to do is to avoid typing out the SET statements in the update query.

ex

$sql = "update myhugedatabase
SET
reporter = '$_POST[reporter]',
date = '$_POST[date]',
district = '$_POST[district]',
village = '$_POST[village]',
school = '$_POST[school]',
address = '$_POST[address]',
teacher = '$_POST[teacher]',
teacher_contact = '$_POST[teacher_contact]',
alt_teach = '$_POST[alt_teach]',
alt_teach_contact = '$_POST[alt_teach_contact]',
gps = '$_POST[gps]',
etc
etc
etc

The reason I want to do this is because I manage many projects all with their own variables and databases and the update is the only part that I have to type in manually.
.



Relevant Pages

  • Re: update mysql without manually tying SET statements
    ... $sql = "update myhugedatabase ... The reason I want to do this is because I manage many projects all with their own variables and databases and the update is the only part that I have to type in manually. ...
    (comp.lang.php)
  • Re: simultaneous multiple requests to very simple database
    ... >>SQL solutions. ... When I look at databases, I see a bunch of very good solutions that are ... level locking. ... The only reason for reluctance is that I have spent too ...
    (comp.lang.python)
  • Re: update mysql without manually tying SET statements
    ... If you don't use a framework, you must type in a SET statement for every single ... You do this nowadays with prepared statements, to be protected against SQL injection ... If you want generic code, you must define the fields and their properties somewhere ...
    (comp.lang.php)