I have a form with fields that are generated dynamically via a loop.
It’s a pair of fields: name/email. Loop generates two input fields for each value. There’s always an email, while name sometimes can be blank.
<div>
<input type="text" name="name['.$i.']" value="'.$output['0'].'">
<input type="text" name="email['.$i.']" value="'.$output['1'].'">
</div>
I understand that $_POST will generate an array, something like this:
Array ( [name] => Array ( [1] => Fname Lname [2] => ) [email] => Array ( [1] => abc@email.com [2] => abc@gmail.com ) )
Once I submit this form how do I get the values into my db table? Having difficulty visualizing this loop with two fields…
You have to choose one of the fields as a reference for the loop: