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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:50:05+00:00 2026-06-04T19:50:05+00:00

I have a update form that populates from a database dynamically, I have two

  • 0

I have a update form that populates from a database dynamically, I have two checkboxes in my form that post to an array so I can hit one submit button and update all rows with a foreach statement. The text fields work as they should, but when the checkbox fields post to their array, they leave out the zeros my arrays become shorter.

How do I add 0 where a null checkbox would be?

this is my form

    <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">

<input type="hidden" name="ss_id[]" value="<?php echo $row_rsSnapshot['ss_id']; ?>" />
<input type="hidden" name="ss_yearmonth[]" value="<?php echo htmlentities($row_rsSnapshot['ss_yearmonth'], ENT_COMPAT, 'UTF-8'); ?>" />
<tr>
  <td>
  <input <?php if (!(strcmp($row_rsSnapshot['ss_inventory'],1))) {echo "checked=\"checked\"";} ?> type="checkbox"  name="ss_inventory[]" value=""  <?php if (!(strcmp(htmlentities($row_rsSnapshot['ss_inventory'], ENT_COMPAT, 'UTF-8'),""))) {echo "checked=\"checked\"";} ?> />

  </td>
  <td>

  <input <?php if (!(strcmp($row_rsSnapshot['ss_write_off'],1))) {echo "checked=\"checked\"";} ?> type="checkbox"  name="ss_write_off[]" value=""  <?php if (!(strcmp(htmlentities($row_rsSnapshot['ss_write_off'], ENT_COMPAT, 'UTF-8'),""))) {echo "checked=\"checked\"";} ?>

  </td>
  <td> 
  <input type="text" name="ss_date[]" value="<?php echo htmlentities($row_rsSnapshot['ss_date'], ENT_COMPAT, 'UTF-8'); ?>" size="32" />
  </td>
  <td>
  <input type="text" name="ss_transaction[]" value="<?php echo htmlentities($row_rsSnapshot['ss_transaction'], ENT_COMPAT, 'UTF-8'); ?>" size="32" />
  </td>...

And here is my sql update query

    foreach($_POST['ss_id'] as $key=>$ss_id){


    $ss_inventory = GetSQLValueString(isset($_POST['ss_inventory'][$key]) ? "true" : "", "defined","1","0");
    $ss_write_off = GetSQLValueString(isset($_POST['ss_write_off'][$key]) ? "true" : "", "defined","1","0");
    $ss_date = $_POST['ss_date'][$key];
    $ss_transaction = $_POST['ss_transaction'][$key];
    $ss_debit = $_POST['ss_debit'][$key];
    $ss_credit = $_POST['ss_credit'][$key];
    $ss_yearmonth = $_POST['ss_yearmonth'][$key];



$sql = "UPDATE snapshot SET ss_inventory = '$ss_inventory', ss_write_off = '$ss_write_off', ss_date = '$ss_date', ss_transaction = '$ss_transaction', ss_debit = '$ss_debit', ss_credit = '$ss_credit' , ss_yearmonth = '$ss_yearmonth' WHERE ss_id = '$ss_id' ";

 mysql_select_db($database_connMyayla, $connMyayla);
 $Result1 = mysql_query($sql, $connMyayla) or die(mysql_error());

}

  }
 mysql_close();
?>
  • 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-06-04T19:50:07+00:00Added an answer on June 4, 2026 at 7:50 pm

    The browser does not submit unchecked checkboxes. You’ll need to either give unique names, or simply use radio buttons.

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

Sidebar

Related Questions

I have a form that enables a user to update multiple alert rules records
I have a MDI container form, and some child forms that update their title
I have an html/php form that updates entries on the database server. I need
I am creating an update form where previously submitted information from a mysql database
I have a struts2 action that builds a form and pre-populates the fields with
I'm using Ruby on Rails to populate a database from a form that has
So I have a form that I want the user to use to update
Technologies: C#, .Net, Winforms I have a main form that pulls data from a
I am designing a database app, and have a form which populates with data
I have a control that, upon postback, saves form results back to the 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.