复选框数组仅返回一个结果 [英] checkbox array only returning one result

查看:68
本文介绍了复选框数组仅返回一个结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立了一个具有复选框输入数组的表单(保存到数组).但是,当我发布它并检索结果时,它仅提供最后的选择.

I have built a form that has a checkbox input array (saving to an array). However, when I POST it and retrieve the results, it only offers the last selection.

<input type="checkbox" value="Friendly" name="quest[9]"> Friendly<br>
<input type="checkbox" value="Attentive" name="quest[9]"> Attentive<br>
<input type="checkbox" value="Enthusiastic" name="quest[9]"> Enthusiastic<br>
<input type="checkbox" value="Understanding" name="quest[9]"> Understanding<br>
<input type="checkbox" value="Well Mannered" name="quest[9]"> Well Mannered<br>
<input type="checkbox" value="Efficient" name="quest[9]"> Efficient<br>
<input type="checkbox" value="Genuine" name="quest[9]"> Genuine<br>

例如,假设我选择了友好",有效"和正版".

For example, say I chose "Friendly", "Efficient", and "Genuine".

当我将其发布到PHP文档并运行时

When I POST it over to a PHP document and run

print_r($_POST['quest']);

我只收到

Array ( [9] => Genuine )

回来,所以正版"是我回来的唯一物品.有没有办法来解决这个问题?我做错了什么?

back so "Genuine" is the only item I get back. Is there a way to fix this? What have I done wrong?

这是调查中的第9个问题,因此不幸的是,不能更改名称.有什么方法可以将结果合并到用逗号分隔的单个数组中?我总是可以在PHP端explode.

This is the 9th question on the survey, so changing the name unfortunately is not an option. Is there any way to combine the results to that single array separated by commas? I could always explode on the php side.

推荐答案

我正在发布有关您对上一个评论的新答案:

I'm posting a new answer about your comments on the previous one:

因为您必须将quest [9]保留为复选框数组的组织..

Since you must keep quest[9] as the organization for the checkbox array..

您可能想尝试使其变得更复杂,其中每个<input>具有name="quest[9][1]"name="quest[9][2]"等.

You may want to try and make it a more complex array, where each <input> has name="quest[9][1]", name="quest[9][2]" and so on.

找到内容

print_r($_POST['quest']);

再次

这篇关于复选框数组仅返回一个结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆