开发者

how to use the arrary of names in post method

开发者 https://www.devze.com 2023-01-17 17:01 出处:网络
<td class=\"widht200\"> <input type=\"text\" name=\"agg\" size=\"2\" disabled=\"disabled\"/> </td><td class=\"widht200\">
<td class="widht200">
<input type="text" name="agg" size="2" disabled="disabled"/> </td><td class="widht200">
<input type="text" name="agg" size="2" disabled="disabled"/></td><td class="widht开发者_StackOverflow社区200"> 
<input type="text" name="agg" size="2" disabled="disabled"/> </td><td class="widht200">
<input type="text" name="agg" size="2" disabled="disabled"/> </td><td class="widht200">
<input type="text" name="agg"  size="2" disabled="disabled"/> </td><td class="widht200">
<input type="text" name="agg"  size="2" disabled="disabled"/> </td><td class="widht200">
<input type="text" name="agg"  size="2" disabled="disabled"/> </td>

i have wrote the code like this.. so now.. i need to post this form.. and agg as an array in php code.. how can i do it..

i used..

$arr[] = $_POST['agg'];

but showed error...


You want to add a the brackets within your html like so:

<input type="text" name="agg[]"  size="2" disabled="disabled"/>

Then just assign it within php like normal:

$arr = isset($_POST['agg']) ? $_POST['agg'] : array();

But you should always have some defined name for your data as you will not know what is what, try use like this:

<input type="text" name="agg[first]"  size="2" disabled="disabled"/>

then within php after you assign it you then can use $arr['first'];

0

精彩评论

暂无评论...
验证码 换一张
取 消