I’m pretty new to PHP and I’m currently working on my first PHP website. I have a need to display (and add/edit) rows in a table in a single form.
What I’m going for is a row in the form for each row in the table plus one blank row so the user can add more items into the table.
When they click the save button I want all the existing rows to update and the new row (if data present) to insert.
Is there an easy way I can iterate through all the controls in a form or something of the sort?
You can iteratore through the $_POST array using the foreach construct, but do not forget to validate the key names against column names (or row names, I can’t grasp your database design, probably because I just woke up).
And if it’s your first PHP website, also don’t forget about SQl injection.