我有大約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