[eluser]bohara[/eluser]
Hi,
I am trying to insert a array into my database. I had this working and I am not sure why it broke.
In my model I have this:
Code:
$reminder_id = $row['id'];
for ($i = 0; $i <= count($_POST['bulb_type_id'])-1; $i++) {
$sql = array(
$this->reminder_id = $reminder_id,
$this->quantity = $_POST['quantity'][$i][1],
$this->bulb_type_id = $_POST['bulb_type_id'][$i][2],
$this->shatterproof = $_POST['shatterproof'][$i][3],
);
}
$this->db->insert('line_items', $sql);
The array part of my form look like this: on the interface you can add more rows through AJAX that increment the the form values like [1][1], [1][2], [1][3], and so on.
Code:
<tbody id="container">
<tr id="row0">
<td>
<input type="text" name="quantity[0][1]" value="" maxlength="2" size="2" />
</td>
<td>
<? echo form_dropdown('bulb_type_id[0][2]', $bulb_types); ?>
</td>
<td>
<? echo form_checkbox('shatterproof[0][3]', 1, false); ?>
</td>
</tr>
</tbody>
I recieve the following errors:
----------------------------------------
A PHP Error was encountered
Severity: Notice
Message: Undefined index: shatterproof
Filename: models/reminder_model.php
Line Number: 67
----------------------------------------
An Error Was Encountered
Error Number: 1054
Unknown column '0' in 'field list'
INSERT INTO `line_items` (`0`, `1`, `2`, `3`) VALUES ('50', '1', '2', NULL)
-----------------------------------------
I hope this is enough information. Thanks in advance