Welcome Guest, Not a member yet? Register   Sign In
retriving data array from multiple checkboxes
#1

[eluser]blorriman[/eluser]
I have a form that selects first_name and last_name from a database and displays them with a checkbox - which works fine:

Code:
foreach ($members->result() as $row) {
    $query = $this->db->get_where('users', array('id' => $row->user_id));
    foreach ($query->result() as $e) {
        echo form_checkbox('name[]', $row->first_name . ' ' . $row->last_name). $row->first_name . ' ' . $row->last_name;
        echo '  ';
    }
}

What I'm totally clueless about is how to retrieve that data. In my controller, I'm just testing :
Code:
echo $this->input->post('name');


In the form, if I use
Code:
form_checkbox('name[]', $row->first_name . ' ' . $row->last_name)
I get "Array", and if I use
Code:
form_checkbox('name', $row->first_name . ' ' . $row->last_name)
- without the [ ] - I get only the last name on the list.

I know I'm missing something really simple and obvious . . . can someone help me please !
#2

[eluser]blorriman[/eluser]
Scratch that . . . I figured it out - in the controller :
Code:
foreach ($this->input->post('name') as $name) {
            echo $name;
        }




Theme © iAndrew 2016 - Forum software by © MyBB