|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Any ideas on how I would allow a user to edit their record in a MySQL database through a PHP script. I want to allow a user to be able to edit/update registration information they have entered previously.
Alternatively, how 'bout a method for pre-filling out a form with data from a MySQL database, allowing the user to edit as necessary, and when submitted posting that record to the database with a new date/time. Any help appreciated!! |
|
#2
|
|||
|
|||
|
This is a very simple procedure.
You just have to read the relevent record from the table and use the fields as value in the HTML <input> tags. To keep this short, I'm assuming you've connected to the db and that $name contains the users name: <? $result=mysql_query("select name,address,city,zip,phone from info where name='$name'"); $data=mysql_fetch_array($result); ?> <form action="changeinfo.php3" method=post> <input type=hidden name="oldname" value="<? print $data[name] ?>"> NAME:<input type=text name="name" value="<? print $data[name] ?>"> Address:<input type=text name="address" value="<? print $data[address] ?>"> // you get the idea then in changeinfo.php3 (assuming you've checked the validity of the entries) you can use this query: "replace into info values ('$name','$address','$city','$zip','$phone') where name='$oldname')" Using the $oldname allows the user to modify the name and still update the old record. However, using a unique index for this would be better. HTH Rod |
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Editing MySQL record with PHP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|