Welcome Guest, Not a member yet? Register   Sign In
Multiple entry update and delete form
#11

[eluser]jpidgeon[/eluser]
Yeah it's returning data on that:

Quote:Array ( [0] => Donna McGrellis [1] => Liam Swift [2] => Mandy Ryan [3] => Margaret Freeman [4] => Stacey Miller )
#12

[eluser]Bart Mebane[/eluser]
OK, we should be almost there. We'll just do this:
Code:
$team = array();
$team['team_name'] = $this->input->post('team_name[' . $index . ']');
$team['owner1'] = $this->input->post('owner1[' . $index . ']');
$team['owner2'] = $this->input->post('owner2[' . $index . ']');
$team['owner3'] = $this->input->post('owner3[' . $index . ']');
That's what I should have done to start with.
#13

[eluser]jpidgeon[/eluser]
It still appears to be filling the fields with "0"s

The fields still don't appear to be getting picked up when I check and submit a row(s)

Code:
function manage_team()
    {
        if ($this->input->post('team_id'))
        {
            foreach ($this->input->post('team_id') as $index => $id)
            {  
                if ($this->input->post('delete'))
                {
                    $this->admin_model->delete_team($id);
                }
                else if ($this->input->post('update'))
                {
                    $team = array();
                    $team['team_name'] = $this->input->post('team_name[' . $index . ']');
                    $team['owner1'] = $this->input->post('owner1[' . $index . ']');
                    $team['owner2'] = $this->input->post('owner2[' . $index . ']');
                    $team['owner3'] = $this->input->post('owner3[' . $index . ']');  
                    
                    print_r( $team );
                    //$this->admin_model->update_team($id, $team);
                }
            }        
        }
        //redirect('/admin/teams', 'refresh');
    }

giving this again:

Quote:Array ( [team_name] => [owner1] => [owner2] => [owner3] => )
#14

[eluser]Bart Mebane[/eluser]
Did you already try echoing $index inside the loop?
#15

[eluser]jpidgeon[/eluser]
Yeah it appears to be echoing that correctly. Both $id and $index are being passed fine
#16

[eluser]Bart Mebane[/eluser]
Running out of ideas, but somehow it's not getting the array element from the input->post. Lets' try this
Code:
function manage_team()
    {
        if ($this->input->post('team_id'))
        {
            $team_name = $this->input->post('team_name');
            $owner1 = $this->input->post('owner1');
            $owner2 = $this->input->post('owner2');
            $owner3 = $this->input->post('owner3');
            foreach ($this->input->post('team_id') as $index => $id)
            {  
                if ($this->input->post('delete'))
                {
                    $this->admin_model->delete_team($id);
                }
                else if ($this->input->post('update'))
                {
                    $team = array();
                    $team['team_name'] = $team_name[$index];
                    $team['owner1'] = $owner1[$index];
                    $team['owner2'] = $owner2[$index];
                    $team['owner3'] = $owner3[$index];  
                    
                    print_r( $team );
                    //$this->admin_model->update_team($id, $team);
                }
            }        
        }
        //redirect('/admin/teams', 'refresh');
    }
#17

[eluser]jpidgeon[/eluser]
That's done it! Thanks you so much for you're help

Would have never figured that out by myself Smile




Theme © iAndrew 2016 - Forum software by © MyBB