How to fetch the GET/POST elements in a form witho

2019-08-04 02:15发布

I had the list of items. When the user clicks a item, a div is generated with a textbox <input type="text" name="(DYNAMICALLY ASSIGNED VALUE)" />

So user can select multiple items. For each item a textbox is generated dynamically inside the form. When the user clicks the submit button, i want to fetch the GET/POSTED elements. How can we achieve that?. plz help. Any help will be appreciated.

标签: php html css forms
2条回答
Fickle 薄情
2楼-- · 2019-08-04 03:01

You could use a foreach loop on $_POST like Matthew suggested or you could set the names of the inputs as an array

for example

<input type="text" name="foo[]">

foreach ($_POST['foo'] as $key => $value) {
    ...
}

The data would look like something like this

[foo] => Array
     (
         [0] => ...
         [1] => ...
         [2] => ...
         [3] => ...
     )
查看更多
贪生不怕死
3楼-- · 2019-08-04 03:08

You can use a for-each loop:

foreach ($_GET as $get_key => $get_value)
查看更多
登录 后发表回答