Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7630211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:02:37+00:00 2026-05-31T06:02:37+00:00

I have checkboxes in my form, which returns me string instead of array, as

  • 0

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:

    <?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>

<?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();
    }
?>
            </table>
            <?php echo form_submit('submit', 'Delete All Selected Users');?>
            <?php echo form_close();?>
        </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:

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

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:02:38+00:00Added an answer on May 31, 2026 at 6:02 am

    EDIT: I just caught this:

    You have nested <form> tags which is invalid and prone to unexpected behavior, you must fix that first (high priority). I can’t tell which one you need to remove because I don’t know your application, but it looks like the ones inside the foreach aren’t supposed to be there, otherwise you wouldn’t need to post an array of values.

    Anyways, assuming that wasn’t the case…


    If this is your code:

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

    Then $deleteWhat in each iteration contains the string that was posted, whatever was in the value of that checkbox.

    This is the array:

    $this->input->post('userdelete')
    

    It contains everything that was posted from form_checkbox('userdelete[]', $user['id'])

    Your code is working fine.

    Just remember a few things:

    • <input name="somename[]"> will post as an array of values because of the brackets.
    • $_POST['somename'] is equal to $this->input->post('somename'), except when the value isn’t set (the first generates an undefined variable notice, the second returns FALSE)
    • You may specify keys like: <input name="somename[hello]">
    • <input name="somename[hello][]"> will post an array of arrays, etc.
    • Checkboxes don’t post anything at all unless they are checked.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page which should show a form with checkboxes, post back if
I need to have a checkbox which ajax-submits a form. The following code throws
I have django form which displays the check boxes.After selecting the checkboxes user will
I have a form which have many check boxes in it. User will check
I have a form with checkboxes and then text to the right of the
I have a HTML form containing checkboxes in the form of .. <input type=checkbox
I have a form with thousands of checkboxes, and when one is checked, I
i have a form with some checkboxes on it i want to save those
I have a form that contains a bunch of checkboxes. Before submitting the form,
I have a form with image thumbnails to select with checkboxes for downloading. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.