Welcome Guest, Not a member yet? Register   Sign In
Array from view to database (HELP)
#6

[eluser]TheFuzzy0ne[/eluser]
I would recommend that you run some validation in there somewhere.

Code:
echo $this->input->post('list_name');



$sql = "INSERT INTO list_img (list_name) VALUES ("
    .$this->db->escape($this->input->post('list_name'))
    .")";
/*
* Avoid running this query until you've validated your input
* otherwise you will end up with database anomalies.
*/

//$this->db->query($sql);

// We don't need to put these into an array, as they already are
// in an array.
$img_name = $this->input->post('name');
$img_que = $this->input->post('queue');

// We only want to process the fields that have been checked,
// so we use the $img_name array as our main reference:
// We only want to check img_que if an entry exists in $img_name.
foreach ($img_name as $key=>$value)
{
    // Just echo the values so you can see what happening.
    echo ""
    . "<p>"
    . "image name: " . $value . "<br />"
    . "image queue: " . $img_que[$key]
    . "</p>\n";
}

// You can modify the above to give you the data you need
// for your database insert.
// THIS is where the database insert should take place.

The code above is untested, but hopefully it should help simplify things for you a little.


Messages In This Thread
Array from view to database (HELP) - by El Forum - 02-11-2009, 03:17 AM
Array from view to database (HELP) - by El Forum - 02-11-2009, 03:35 AM
Array from view to database (HELP) - by El Forum - 02-11-2009, 03:43 AM
Array from view to database (HELP) - by El Forum - 02-11-2009, 03:51 AM
Array from view to database (HELP) - by El Forum - 02-11-2009, 04:01 AM
Array from view to database (HELP) - by El Forum - 02-11-2009, 04:57 AM
Array from view to database (HELP) - by El Forum - 02-12-2009, 01:58 AM
Array from view to database (HELP) - by El Forum - 02-12-2009, 03:35 AM
Array from view to database (HELP) - by El Forum - 02-12-2009, 06:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB