Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy I am getting string instead of array from my checkboxes?
    text
    copied!<p>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?</p> <p>Here is the code from the view:</p> <pre><code> &lt;?php echo form_open('backOfficeUsers/deleteMoreUsers');?&gt; &lt;table border="0" cellpadding="4" cellspacing="1" bgcolor="#02659E" width="500"&gt; &lt;tr bgcolor="#E9E8ED"&gt; &lt;td align="center"&gt; &lt;b&gt;User ID&lt;/b&gt; &lt;/td&gt; &lt;td align="center"&gt; &lt;b&gt;User Name&lt;/b&gt; &lt;/td&gt; &lt;td align="center"&gt; &lt;b&gt;Password&lt;/b&gt; &lt;/td&gt; &lt;td align="center"&gt; &lt;b&gt;Select for delete&lt;/b&gt; &lt;/td&gt; &lt;td align="center"&gt; &lt;b&gt;Delete&lt;/b&gt; &lt;/td&gt; &lt;/tr&gt; &lt;?php foreach ($users as $key =&gt; $user) { echo form_open('backOfficeUsers/deleteUser'); echo form_hidden('dpage', 'backOfficeUsers/displayAllUsers'); echo form_hidden('rid', $user['id']); echo"&lt;tr bgcolor='#E9E8ED'&gt;"; echo "&lt;td&gt;" . anchor("backOfficeUsers/displayEditUserForm/$user[id]/", $user['id']) . "&lt;/td&gt;"; echo "&lt;td&gt;" . $user['username'] . "&lt;/td&gt; "; echo "&lt;td&gt;" . $user['password'] . "&lt;/td&gt; "; echo "&lt;td&gt;" . form_checkbox('userdelete[]', $user['id']) . "&lt;/td&gt; "; $confirm = "onclick='return confirmSubmit();'"; echo"&lt;td&gt;"; echo form_submit('submit', 'Delete', $confirm); echo"&lt;/td&gt;&lt;/tr&gt;"; echo form_close(); } ?&gt; &lt;/table&gt; &lt;?php echo form_submit('submit', 'Delete All Selected Users');?&gt; &lt;?php echo form_close();?&gt; &lt;/div&gt; </code></pre> <p>And when I make var dump from my controller, I am getting string string(3) “200” (while 200 is the row id.</p> <p>Here is the code of the controller:</p> <pre><code>foreach ($this-&gt;input-&gt;post('userdelete') as $row){ $deleteWhat = $row; var_dump($deleteWhat); die(); } </code></pre> <p>This print string(3) and the id of the first row.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload