Here is a complete solution for adding rows to a form. This sample script displays a form for insert and update products. When clicking on the link [+], we add a new product line. It also includes the update by sending the "mod" parameter corresponding to the ID of the MySQL table row to edit.
Dynamic system for adding rows : Initially, the PHP script creates 100 form lines, but displays only the first. The following are hidden by the CSS display:none. The names of the form fields are one array that is incremented every row. When recording, this table is serialized into a string of characters to fit into a MySQL TEXT type field. To retrieve this table, simply use the opposite function : unserialize()