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 686315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:00:43+00:00 2026-05-14T02:00:43+00:00

I have an array of checkboxes that I edit at once to set up

  • 0

I have an array of checkboxes that I edit at once to set up a ‘tinyint’ field. the problem comes in when i uncheck the checkbox and post the vales to mysql. since it posts an array of checkboxes and another parallel array of values to edit, unchecking a checkbox results in the 0 value been ignored by PHP_POST and hence the checkbox array will be less by the number of unchecked values in the form while the array to be edited will have all the records in the form.

here is the submit code

while($row=mysql_fetch_array($result))
{

$checked = ($row[active]==1) ? 'checked="checked"' : '';
...

echo "<input type='hidden' name='TrID[]' value='$TrID'>";
echo "<input type='checkbox' name='active1[]' value='$row[active]''$checked' >";
...

and the processing php script

$userid = ($_POST['TrID']);
$checked= ($_POST['active']);

$i=0;

foreach ($userid as $usid) 
{

if ($checked[$i]==1){
$check = 1;
}
else{
$check = 0;
}

$qry1 ="UPDATE  `epapers`.`clientelle` SET  `active` =  '$check' WHERE  `clientelle`.`user_id` =  '$usid' ";
$result = mysql_query($qry1);   
$i++;

}
  • 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-14T02:00:43+00:00Added an answer on May 14, 2026 at 2:00 am

    You could try something like:

    $i = 0;
    while($row=mysql_fetch_array($result))
    {
    
    $i++;
    $checked = ($row[active]==1) ? 'checked="checked"' : '';
    ...
    
    echo "<input type='hidden' name='TrID[{$i}]' value='$TrID'>";
    echo "<input type='checkbox' name='active1[{$i}]' value='$row[active]''$checked' >";
    ...
    

    The checkboxes should then at least be in the proper place in the array…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have an array of checkboxes e.g. <input type=checkbox name=checks[] value=1 /> <input
I have an array (for checkboxes) that I need to pass alongside the regular
I have a asp.net mvc page with an array of checkboxes that gets posted
I am trying to get an array of checkboxes that ARE checked AND have
I have an array of checkboxes that gets built from a smarty template. When
I have a group of checkboxes that I'm trying to pass through POST via
I have some checkboxes bound to an array in my model. This works great,
I am going nuts here, I have an array of checkboxes from a form
I have my checkbox for a bool field like so in my view: =Html.CheckBox(Active,
I have a list of checkboxes that I want to insert into a database,

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.