简体   繁体   中英

PHP - input a list of input fields into a database

New.php (form) This has a section where you can clone input fields and the values go into array. When posting, these values are then added to the database via a foreach loop.

eg <input type="text" name="number[]" />

Edit.php (form) I now extract all the rows from the data and put them into a list of input fields.

How do i update a mysql entry for that particular value? Normally with ajax and jquery, i can get the rowid from 'data-rowid' i generated and then update where rowid = x. What about on submit. Would it need to go back into an array or how can i check against a row id?

Your help appreciated.

You would need to submit rowid as a hidden input field so it is posted along with all your other information. That way when you get to edit.php you have the information you need.

<input type="hidden" name="rowid" value="1">

And then on edit you can do :

$rowid = $_POST['rowid'];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM