I have got a form with some inputs like:
<form action="http://site.com" method="post" accept-charset="utf-8">
<input type="text" name="image_Title" value="Image" />
<input type="text" name="image_Basename" value="0000001" />
<input type="text" name="image_basename" value="0000002" />
<input type="text" name="image_basename" value="0000003" />
</form>
How can I insert each image_Id with the same image_Title to one row using Codeigniter?! I used foreach, but I couldn't make it work?!
for example:
table-row-name:image_Title table-row-name:image_Basename
'Image' '00000001'
'Image' '00000002'
'Image' '00000003'
'Image2' '00000258'
'Image2' '00000102'
How can I do that ?!
This is my php code ( of cource in Codeigniter):
foreach($_POST['image_Basename'] as $image_Basename)
{
$image_Id = $this->gallery_model->add(array('image_Title' => $_POST['image_Title'], 'image_Basename' => $image_Basename));
}
My Model:
function add($options = array())
{
$options = array(
'image_Title' => $_Post['image_Title'],
'image_Basename' => $image_Basename
);
$this->db->insert('mg_gallery', $options);
return $this->db->insert_id();
}