I know this old post, but just run into it looking for something else. Another solution to this problem, which is now available 3 years later, is to place arrays of text fields and the identifier of the line you want to keep or delete.
Something like:
<form> <table> <tr> <td><input type="text" name="row_id[1]" value="1"></td> <td><input type="text" name="five[1]" value="5"></td> <td><input type="text" name="three[1]" value="3"></td> <td> <button name="action" type="submit" value="delete_1">Delete</button> <button name="action" type="submit" value="save_1">Save</button> </td> </tr> <tr> <td><input type="text" name="row_id[2]" value="2"></td> <td><input type="text" name="five[2]" value="7"></td> <td><input type="text" name="three[2]" value="10"></td> <td> <button name="action" type="submit" value="delete_2">Delete</button> <button name="action" type="submit" value="save_2">Save</button> </td> </tr> </table> </form>
You can, of course, repeat the rows of the table as often as you want. Each of them has a unique identifier, which is contained in the value of the action button, as well as in an array of input fields. For example, if you click the "Delete" button in the second line, you will get the ACTION value "delete_2" on the server. A quick split, explosion, or similar action will then give you an ACTION and an identifier.
For the save function, you can simply use this identifier to call the corresponding text fields from the corresponding arrays.
This method allows you to embed the entire table in one form.
As a side point, since the DELETE function probably does not require the use of any other variables, since they are rarely updated and then deleted in one go, you can achieve the same goal with a simple URL and a GET parameter for the identifier. However, be careful, as you can allow your users to delete multiple entries by simply changing the URL variables and linking to the page again and again.
Hope this helps someone, and again I realize this is an old post.
source share