Editing the Table

While it is all fine and good to see a dump of a database table's contents, as well as search a table for information, many times the table needs to be dynamically modified -- a new record (row) needs to be added, existing information needs to be changed, or an existing record must be deleted. This involves more work with HTML forms to accept the user input for new or changed information, as well as a mechanism to select which row should be edited (updated) or deleted.

The key idea is to use a key -- something in the record's data that uniquely identifies it. If a unique key can't be found, then when you ask to update records containing the key, you will be updating all records that match the key. That could be what is desired, or it could be a problem. If you need a unique key, you could add a column to your table that contained a unique number for each record, and use that id number. This is common practice, and makes joining tables fast and storage-efficient.

A simple way of providing the user with an ability to add, edit or delete records is to link to scripts and web pages that allow those actions. An add link needs to allow entry of the data for each column. Edit and delete links need to specify the unique key of the record to edit or delete. In particular, an edit web page should display the current contents of the record to allow easier corrections and updates to the contents, while a delete action should confirm the choice that the user requested and allow cancellation of the delete action, in case a mistake was made.

Add and edit web pages contain the same information to fill in or change, usually denoted by the name of the column or a descriptive label and a place to set or modify the value associated with it. The means for displaying or changing a value depend on the designer of the web page as well as the capabilities of the HTML <input> tag, but there are some fairly universal user interface guidelines.