[eluser]murphy2006[/eluser]
Hello Guys,
I have a simple problem. I am developing an online photo album and I want the users to be able to update ALL image descriptions on one page.
How can this be done? I have tried with some kind of foreach loop but fail.
I have namned each description field desc[] and added an hidden ID field for each image by the name of the_id[] with the database ID of the image.
The controller looks like the below code, what is wrong, who can it be fixed?
Code:
///////////////////////////////////////////////////////////
//
// Gather the incoming data into variables
//
///////////////////////////////////////////////////////////
$owner = $this->session->userdata('id');
foreach ($_POST['desc'] as $desc) {
foreach ($_POST['id'] as $id) {
$the_id = $id;
}
///////////////////////////////////////////////////////////
//
// Put the incoming date in variables
//
///////////////////////////////////////////////////////////
$data = array(
'aco_desc' => $desc
);
///////////////////////////////////////////////////////////
//
// Delete the selected feed
//
///////////////////////////////////////////////////////////
$this->db->where('aco_owner', $owner);
$this->db->where_in('aco_id', $the_id);
$this->db->update('fe_albums_content', $data);
}
The problem is that it isnĀ“t updating each image only the last one.
Thankful for a quick reply.