Databases :: MySql :: Updating table from a HTML form using |
|||
| By: ICT |
Date: 07/02/2003 00:00:00 |
Points: 75 | Status: Answered Quality : Excellent |
|
Hi I am creating a process which reads a tables field names into an array and then uses this array to present the filed names with associated data for a particualr row in a HTML form. This same form is used to allow the user to enter/edit the data and on clicking "update" button I wish to use this same array of variables to update all the fields for that particular row of the table. That is the code does not know the names of the fields. My problem is the syntax of the mySQL update or insert or whatever command. I think that makes sense. Thanks Ian |
|||
| By: VGR | Date: 07/02/2003 06:34:00 | Type : Comment |
|
| no problem, I wrote one page like this for maintaining any DB I could have . I suggest UPDATE if your unique id field of the table is declared auto_increment This way, setting 0 in the id field provokes an insert, and letting in the existing value does an update i think this is clear |
|||
| By: bobbit31 | Date: 07/02/2003 19:27:00 | Type : Comment |
|
| what application server are you using? ASP/JSP/Other? |
|||
| By: ICT | Date: 08/02/2003 02:03:00 | Type : Comment |
|
| Thanks for that, in answer to the first comment, I am using php. Maybe my problem is more on the html to mysql side. That is, if I have a form in html with 10 edit fields how do I use arrays as the variables to read these values from the form so that I can then use this array to update on the mySQL command. Ian |
|||
| By: VGR | Date: 08/02/2003 02:29:00 | Type : Answer |
|
| it's not necessary to use an array, especially provided HTML has problems handling arrays (and matrices) I use normal PHP variables whose names are F ("F" like "FORM" ;-) followed by the fields' name as from the DB something like this : ${'F'.$globChNom[$globNbChamps-1]} |
|||
| By: ICT | Date: 09/02/2003 21:24:00 | Type : Comment |
|
| Thanks VGR, I will try and integrate your suggestion to see if this solves the problem. Ian |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








