What you want to accomplish is in essence a CRUD structure. You want to:
C reate
R ead
U pdate
D elete
I would suggest to read tutorials like: Click here for a tutorial in CRUD and practice with the structure and mind-set. When you have completed one or more tutorials, then go back to this question and try to answer your own question. I think this would be the best way to learn.
What you are asking for is very basic and can be done easily by creating CRUD operation, which include Create, Read, Update and Delete operations. There are three ways to do it:
Single Query Execution
Multi Queries Execution
Prepared Statement Execution
You have to start this with selecting the data from your database using single query execution.
Then you can update and delete using prepared statement.