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()
Tested with
Safari Google Chrome Firefox3 Firefox4 Opera IE6 IE7 IE8
Rate this code
|
Copied : 300x
Comments for Dynamically add rows to a form. Complete solution
RussellDaf01/28/2017 19:02
No need to look anywhere else, the most advanced Pokemon Duel Cheat is available right now for you to download. Promo: BODM77BWH223BE
Johne20901/01/2015 05:37
Very well written article. It will be helpful to anyone who usess it, as well as yours truly
rem02/12/2013 15:24
coucou
Nico01/05/2012 08:15
Serialize function doesnt transmit the null value of the array
D6_01/04/2012 05:57
Question - If you create a hundred form elements, displayed or not, when the user hits submit, that info is passed to the action page. How does the action page know to only look at the number of elements that was chosen by the user?
No need to look anywhere else, the most advanced Pokemon Duel Cheat is available right now for you to download. Promo: BODM77BWH223BE