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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:25:16+00:00 2026-06-16T01:25:16+00:00

I have a simple form containing 5 textareas and a checkbox next to each

  • 0

I have a simple form containing 5 textareas and a checkbox next to each textarea. The textarea and checkbox values are set to arrays. I then loop through the array for the textarea and insert the records. The textarea values are working fine, but the checkbox values aren’t working as they need to.

The form:

<form action="" method="post" name="form">
<table border="0" align="left" cellpadding="5">
  <tr>
    <td valign="top">Submission</td>
    <td valign="top"><p>Allowed</p></td>
    <td valign="top">Comment</td>
  </tr>
  <tr>
    <td width="13%" valign="top">Prescription</td>
    <td width="13%" align="center" valign="top"><input name="submission[]" id="submission_1" type="checkbox" value="0" /></td>
    <td width="74%" valign="top"><textarea name="comment[]" cols="45" rows="5"></textarea></td>
  </tr>
  <tr>
    <td valign="top">Lab Request</td>
    <td align="center" valign="top"><input name="submission[]" id="submission_1" type="checkbox" value="1" /></td>
    <td valign="top"><textarea name="comment[]" cols="45" rows="5"></textarea></td>
  </tr>
  <tr>
    <td valign="top">Generic request</td>
    <td align="center" valign="top"><input name="submission[]" id="submission_1" type="checkbox" value="2" /></td>
    <td valign="top"><textarea name="comment[]" cols="45" rows="5"></textarea></td>
  </tr>
  <tr>
    <td valign="top">Image request</td>
    <td align="center" valign="top"><input name="submission[]" id="submission_1" type="checkbox" value="3" /></td>
    <td valign="top"><textarea name="comment[]" cols="45" rows="5"></textarea></td>
  </tr>
  <tr>
    <td valign="top">Stationery</td>
    <td align="center" valign="top"><input name="submission[]" id="submission_1" type="checkbox" value="4" /></td>
    <td valign="top"><textarea name="comment[]" cols="45" rows="5"></textarea></td>
  </tr>
  <tr>
    <td colspan="3" valign="top"><input type="submit" name="define_submissions" id="submit" value="Add Submissions" /></td>
  </tr>
</table>
</form>

The PHP:

$submission = intval($_POST['submission']);
$submission_comment = $_POST['comment'];


if(isset($_POST['define_submissions'])){ 

for($i=0, $count = count($submission_comment);$i<$count;$i++) {
    $comment = $submission_comment[$i];
    $query_level_1 = 
sprintf("INSERT INTO submission (             
           submission_pk,
           pathway_fk,
           submission_allowed,
           comment
        ) VALUES (
           '',
           '$pathway',
           '%s',
           '$comment')", $submission === $i ? 'y' : 'n');
$result_level_1 = mysql_query($query_level_1, $connection) or die(mysql_error());
}
  • 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-16T01:25:18+00:00Added an answer on June 16, 2026 at 1:25 am

    AFAIK, checkbox value are not sent to server, when not checked. So, you need to, first, check if it is exists / defined.

    To make it easier, just add key value to your check box:

    <input name="submission[0]" id="submission_1" type="checkbox" value="0" />
    <input name="submission[3]" id="submission_1" type="checkbox" value="3" />
    

    And then, define the $submission:

    $submissions = $_POST['submission'];
    

    Inside for loop:

    $submission = isset($submissions[$i]) ? 'n' : 'y';
    

    And change your query line into:

    '$comment')", $submission);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have simple form containing four textareas and a radio group with a radio
I have a simple in VB/ASP.NET form containing two text boxes, I am attempting
I have simple form like this which accepts only two values string action and
Using PHP, I have a form containing a simple list of items with a
In my application I have a simple XML formatted file containing structured data. Each
I have a simple form containing a main view and also some text boxes
I have a very simple HTML form, only containing a submit button and a
I have this simple piece of code on a windows form containing said DataGridView
I have a number of vectors of strings each containing dates. As a simple
I've created new Windows Forms Application (C#) with one simple form containing ListView. Then

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.