我有大约50输入复选框一个页面,其中他们循环执行复选框-php
name="form[]"
我需要我的PHP脚本能够遍历所有的复选框和以往那些被检查并提交我需要放入一个变量,所以我可以存储哪些形式给定。
这是我的循环:
if ($this->input->post('action') == 'additional') { // Checks if radio button was checked
foreach ($this->input->post('form') as $forms) { // If above ^^^ is true loop through form[]
$givenforms = ', '.$forms.''; // What ever form[] is in the array assign them to the givenforms variable
}
$comments = 'This student was given'.$givenforms.''; // The comment I want to store in the database
}
这工作,但对于只有一种形式(复选框)。如果由于某种原因,我的客户需要给学生全部50份表格,我希望$ comment ='这个学生被授予......................... ..........................(全部50份表格)'
任何链接或小费将不胜感激。
这是CodeIgniter的权利?最好将框架添加到标签中。 – 2013-04-06 17:59:44
哦,真抱歉!我现在就这样做! – 2013-04-06 18:02:45
也只是为了增加,两个答案产生相同的确切结果! Fabricio刚刚回答。 – 2013-04-06 18:07:57