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…

This is the image of the table, the values here are in text boxes but readonly when the user clicks first edit the first row should be writable and the entered values should store

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.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!