How do I make an editable HTML table with content taken from a database table and update the edits back in the database table all at once?

I want to make a web page which displays the contents of a table in my database. I want to make a few fields of the displayed content editable. Upon making the edits to multiple rows, I want to make an “update” button which when pressed, reflects all the changes made in the front-end, back in the database table.

For example, consider a student table in the database like:
|ID|Name|Marks1|Marks2|Marks3|

  • this table will first be shown on the web page with whatever records it holds
  • the user can edit Marks1 Marks2 and Marks3 columns
  • the user may edit any number of records
  • when user clicks “update”, the changes made will also reflect in the database table’s Marks1 Marks2 and Marks3 columns.

What I can’t wrap my head around is how I can make this editable table in the front-end that can bulk update records in the database table. I need to send the edited values via a post request to the back-end, where I can update the rows in database table. Once I get the values from this magical front-end, I can do something like

//pseudo-code
foreach(changed record from front-end table)
{
    fetch changed values
    make insert query
    update the database table
}

I just need to find a way to make the HTML page that does what I have described.

I tried to use editable cells in but I am not able to fetch those values and send them to the back-end for further processing. I don’t have an executable code yet, but I will be posting them in the coming updates to this question, after incorporating initial suggestions.

Can you suggest me how I can make this editable table?

Firstly, welcome back to the forum.

While we are primarily here to help people with their Free Code Camp progress, we are open to people on other paths, too. Some of what you are asking is pretty trivial in the Free Code Camp context, so you might find that if you’re not getting the instruction and material you need in your current studies, the FCC curriculum will really help you get started. At a modest guess I’d say investing a 4-5 hours working through the curriculum here will really pay off. You can find the curriculum at https://freecodecamp.org.

With your current questions, we don’t have enough context to know what you already know or don’t know, so it is impossible to guide you without just telling you the answer (which we won’t do).

It is pretty typical on here for people to share a codepen / jsfiddle example of what they have tried so that anyone helping has more of an idea of what help is actually helpful.

Please provide some example of what you’ve tried and I’m sure you’ll get more help.

Happy coding :slight_smile:

1 Like