php - Form With Unlimited Fields -
i have form has [add fields] option making possible add virtually unlimited item numbers , descriptions.
these fields named: item[]
, desc[]
(brackets arrays).
my question is, how submit information php , mysql each row (item , description) submitted it's own row in database?
i've tried multiple methods submitting item[0] , desc[0] no avail :(
thanks of in advance!
edit: below i've been trying use... (sorry, not great arrays...)
$count = 0 foreach ($_post['item'] $item) { $query = "insert items (item, desc) values ('" . $item[$count] . "', '" . $_post['desc'][$count] . "')"; // script simplified quite complex. if ($query_result) { $count++; } }
you can loop through 1 of input field using foreach loop , access other fields.
foreach($_post['item'] $key => $item){ //your code $desc = $_post['desc'][$key]; }
edit : per code script like
$count = 0 foreach ($_post['item'] $key => $item) { $query = "insert items (item, desc) values ('" . $item . "', '" . $_post['desc'][$key] . "')"; // script simplified quite complex. if ($query_result) { $count++; } }
Comments
Post a Comment