Welcome Guest, Not a member yet? Register   Sign In
Insert array into database
#11

[eluser]Randy Casburn[/eluser]
Maybe I've misunderstood your intent with this:

Code:
$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]
                    );

When I look back at this, it looks like your intent really is to say I want $reminder_id to be assigned to the Class variable named reminder_id and I want the POST'd value from array index 'quanity'[$i][1] to be assigned to the Class variable quantity etc.

So I led you astray before. If that is your intent. But if that is true, you are not ready to pass that to the db->insert method yet. First, you must build the array properly. And that is your current problem.

So do this:

1) change the => operators back to = operators
2) change $sql array stuff to this:

Code:
$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]

3) now set up the array for the insert function:

Code:
$data = array(
         "REMINDER COLUMN NAME HERE" => $this->reminder_id,
         "QUANTITY COLUMN NAME HERE" => $this->quantity,
         "BULB_TYPE COLUMN NAME HERE" => $this->bulb_type_id,
         "SHATTERPROOF COLUMN NAME HERE" => $this->shatterproof,
                    );

4) change your insert statement to say: $this->db->insert('line_items', $data);

============

Let's try this. let me know what your questions are .

Randy


Messages In This Thread
Insert array into database - by El Forum - 07-23-2008, 12:38 PM
Insert array into database - by El Forum - 07-24-2008, 08:30 AM
Insert array into database - by El Forum - 07-24-2008, 10:08 AM
Insert array into database - by El Forum - 07-24-2008, 10:25 AM
Insert array into database - by El Forum - 07-24-2008, 10:34 AM
Insert array into database - by El Forum - 07-24-2008, 10:38 AM
Insert array into database - by El Forum - 07-24-2008, 10:41 AM
Insert array into database - by El Forum - 07-24-2008, 10:43 AM
Insert array into database - by El Forum - 07-24-2008, 10:48 AM
Insert array into database - by El Forum - 07-24-2008, 11:00 AM
Insert array into database - by El Forum - 07-24-2008, 11:49 AM
Insert array into database - by El Forum - 07-24-2008, 12:04 PM
Insert array into database - by El Forum - 07-24-2008, 12:09 PM
Insert array into database - by El Forum - 07-24-2008, 01:44 PM
Insert array into database - by El Forum - 08-26-2008, 12:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB