php - Form With Unlimited Fields -


mockup of form i'm trying submit through php in rows

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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -