Welcome Guest, Not a member yet? Register   Sign In
Urgent help with multiple updates in DB, please!
#1

[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.


Messages In This Thread
Urgent help with multiple updates in DB, please! - by El Forum - 10-04-2008, 07:57 AM
Urgent help with multiple updates in DB, please! - by El Forum - 10-04-2008, 09:54 AM
Urgent help with multiple updates in DB, please! - by El Forum - 10-04-2008, 10:07 AM
Urgent help with multiple updates in DB, please! - by El Forum - 10-04-2008, 11:20 AM
Urgent help with multiple updates in DB, please! - by El Forum - 10-04-2008, 11:28 AM
Urgent help with multiple updates in DB, please! - by El Forum - 10-04-2008, 04:15 PM
Urgent help with multiple updates in DB, please! - by El Forum - 10-04-2008, 11:34 PM
Urgent help with multiple updates in DB, please! - by El Forum - 10-05-2008, 03:30 AM
Urgent help with multiple updates in DB, please! - by El Forum - 10-05-2008, 02:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB