...form data...
So basically I have it set up so on the click of a button I can add more fields to the current form. Example: Multiple drops (of items) from chopping a tree.
echo "<table><tr><td>Drops: <select name=\"input4-a[]\" id=\"items\">";
echo $items;
echo "</select> </td>";
echo "<td>[Chance: <input type=\"text\" name=\"input4-b\" style=\"width:80px;\" value=\"30 / 3000\"/> ]</td></tr></table>";
So its basically there so I can add many drops to the chopping a tree.
What I need is to collect the values from input4-a and input4-b so I can insert the data ($_POST[input4-a] & $_POST[input4-b]) into the drops table.
Any ideas?
For each? Loop? Many Form Fields with DB insert
For each? Loop? Many Form Fields with DB insert
Just follow your arrow wherever it points
Re: For each? Loop? Many Form Fields with DB insert
It's like this But I need id1 and id2 and then they need to get inserted into the same Drops table.


Just follow your arrow wherever it points
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: For each? Loop? Many Form Fields with DB insert
not sure exactly what you are going for but
Code: Select all
document.getElementById("id" + $key).value
Re: For each? Loop? Many Form Fields with DB insert
I managed to find this online somewhere and worked out for me! Here's what I used in case someone else comes across this.
Code: Select all
for ($i=0; $i < count($_POST['id']); $i++) {
$drop_id = $_POST['id'][$i];
$drop_chance = $_POST['id2'][$i];
//Insert Query
}
Just follow your arrow wherever it points