我有問題,如果有人可以幫助將不勝感激。codeigniter通過選定的複選框插入多行
<input type="checkbox" name="symbols[]" value="1" />
.... and this line repeats 10-15 times with a different value
模型
$data = array(
array('symbol_id' => $this->input->post('symbols'))
);
return $this->db->insert_batch('symbols', $data);
我現在的問題是,是將所選擇的複選框的只有第一個值(在這種情況下,1),而忽略其他一切不插入其他複選框的新行(如價值3,5和9)。 你能給我一些建議嗎?
注意:我想實現的是爲每個複選框插入一個新行,所以我可以加入另一個表中包含符號圖像(表示圖像的id的複選框的值)。 如果您有任何其他方法可以做到這一點,非常受歡迎。 謝謝
編輯:這是的var_dump:
array(7)
{
[0] => string(1) "8"
[1] => string(1) "9"
[2] => string(2) "10"
[3] => string(2) "11"
[4] => string(2) "12"
[5] => string(2) "13"
}
可能重複的[插入通過一個php陣列到MySQL的多個行(http://stackoverflow.com/questions/779986/insert-multiple-rows-via-a-php -array-into-mysql) –