Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #6088
| Date | 2012-05-17 07:09 -0400 |
|---|---|
| From | bill <nobody@spamcop.net> |
| Newsgroups | comp.lang.php |
| Subject | Re: update mysql without manually tying SET statements |
| References | <23804394.335.1337177557295.JavaMail.geo-discussion-forums@ynlm14> |
| Message-ID | <x76dndyBOK3nQSnSnZ2dnUVZ_vadnZ2d@cablespeedmi.com> (permalink) |
On 5/16/2012 10:12 AM, apavluck@gmail.com wrote: > 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. if you have all the data in the row (or hidden fields) you can just do a REPLACE instead of the UPDATE bill
Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread
update mysql without manually tying SET statements apavluck@gmail.com - 2012-05-16 07:12 -0700
Re: update mysql without manually tying SET statements Shake <QUITAESTO@QUITAESTO.NOES> - 2012-05-16 16:23 +0200
Re: update mysql without manually tying SET statements Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-16 18:06 +0200
Re: update mysql without manually tying SET statements apavluck@gmail.com - 2012-05-17 11:06 -0700
Re: update mysql without manually tying SET statements Shake <alex.estevezQUENO@QUENOfilnet.es> - 2012-05-17 21:06 +0200
Re: update mysql without manually tying SET statements "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-05-16 22:48 +0200
Re: update mysql without manually tying SET statements IRC <ircadhikari@gmail.com> - 2012-05-17 04:14 -0700
Re: update mysql without manually tying SET statements Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-05-18 10:49 +0200
Re: update mysql without manually tying SET statements bill <nobody@spamcop.net> - 2012-05-17 07:09 -0400
csiph-web