Reputation: 412
On one of my pages I pull a table of data from the database and display it to the user, giving them the option to update the values for each row. My question is what is the best way to do this?
Currently, i'm stuck between two options. Option one is to display one form with all of the inputs. My other idea was to have each row be a form itself. Is there an advantage to one over the other? Right now i'm leaning towards the the latter of the two - as it seems like much less overhead to only POST data for one row as opposed to all of them for a single update.
Upvotes: 1
Views: 891
Reputation: 502
you could set it up so that when a record is clicked the data for that record(id,name,other...) are loaded into a form in a jQuery ui dialog then have two buttons on the dialog (save,cancel)
Save: use ajax to send the data to a php data helper which will update the record in the database
cancel: clear the fields in the form and close the dialog
Upvotes: 1
Reputation: 78691
You should certainly define separate forms for every row. No need to send all the data all the time.
Semantically, they are also separate forms. It is also easier to handle the data you get on the server side.
Upvotes: 2