CodeIgniter Forums
why I am getting string instead of array from my checkboxes?? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: why I am getting string instead of array from my checkboxes?? (/showthread.php?tid=50036)



why I am getting string instead of array from my checkboxes?? - El Forum - 03-12-2012

[eluser]zoreli[/eluser]
Hi

I have checkboxes in my form, which returns me string instead of array, as it should. Can anyone tell me what is wrong with my code?

Here is the code from the view:

Code:
<?php echo form_open('backOfficeUsers/deleteMoreUsers');?>
            <table border="0" cellpadding="4" cellspacing="1" bgcolor="#02659E" width="500">
                <tr bgcolor="#E9E8ED">
                    <td align="center">
                        <b>User ID</b>
                    </td>
                    <td align="center">
                        <b>User Name</b>
                    </td>
                    <td align="center">
                        <b>Password</b>
                    </td>
                    <td align="center">
                        <b>Select for delete</b>
                    </td>
                    <td align="center">
                        <b>Delete</b>
                    </td>
                </tr>
                
&lt;?php
  
    foreach ($users as $key => $user)
    {
        echo form_open('backOfficeUsers/deleteUser');
        echo form_hidden('dpage', 'backOfficeUsers/displayAllUsers');
        echo form_hidden('rid', $user['id']);
        echo"<tr bgcolor='#E9E8ED'>";
        echo "<td>" . anchor("backOfficeUsers/displayEditUserForm/$user[id]/", $user['id']) . "</td>";
        echo "<td>" . $user['username'] . "</td>  ";
        echo "<td>" . $user['password'] . "</td>  ";
         echo "<td>" . form_checkbox('userdelete[]', $user['id']) . "</td>  ";
        $confirm = "onclick='return confirmSubmit();'";
        echo"<td>";
        echo form_submit('submit', 'Delete', $confirm);
        echo"</td></tr>";
        echo form_close();
    }
?&gt;
            </table>
            &lt;?php echo form_submit('submit', 'Delete All Selected Users');?&gt;
            &lt;?php echo form_close();?&gt;
        </div>

And when I make var dump from my controller, I am getting string string(3) "200" (while 200 is the row id.

Here is the code of the controller:

Code:
foreach ($this->input->post('userdelete') as $row){
            $deleteWhat = $row;
            }

var_dump($deleteWhat);
            die();

This print string(3) and the id of the first row.

Regards, Zoreli


why I am getting string instead of array from my checkboxes?? - El Forum - 03-12-2012

[eluser]Noobigniter[/eluser]
Code:
foreach ($this->input->post('userdelete') as $row){
            $deleteWhat[] = $row;
            }
?