June 18, 2012
about editing only 1 row in a table
Question by Triveni Gaikwad
How to edit a row in mysql using php.
I have a table , i will fetch it into php page to display the table in html format and at the end i have a edit button when i click edit button then the row should be editable and i can enter new values and that should update in the same table row.. after c licking edit button the button should change to submit/update…
Answer by Starx
This is one of the basic actions, which falls into the category of CRUD functions. Here are the few steps you need to know to get you started.
- Pass a unique id of the record a edit page or class.
- You may attach the
id
, to the edit link of each page. - This page will use this
id
and fetch the record from the database - The details will be used to fill up of a form, from which the user will update the records.
- The form will also keep the record of the
id
in most probably a hidden element. - Next, when this edit form is submitted, a processing will create a
UPDATE
query based on the data and execute them.