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

  • Home
  • SEARCH
  • 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 6135571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:29:44+00:00 2026-05-23T17:29:44+00:00

Here is simple form contain multiple checkboxes options and textarea input: <form method=post name=form1

  • 0

Here is simple form contain multiple checkboxes options and textarea input:

    <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
    <table>
    <tr><th colspan="2">BREATHING CIRCULATION</th></tr>
    <tr><th>#</th><th>Instruction Name</th></tr>
    <tr><td><input name="InstrCheck[]" type="checkbox" id="InstrCheck" value="Respirations normal rate"></td><td>Respirations normal rate</td></tr>
    <tr><td><input name="InstrCheck[]" type="checkbox" id="InstrCheck" value="Respirations effort normal"></td><td>Respirations effort normal</td></tr>
<tr><td><input name="InstrCheck[]" type="checkbox" id="InstrCheck" value="Breath Sounds-normal"></td><td>Breath Sounds-normal</td></tr>
    <tr><td><input name="InstrCheck[]" type="checkbox" id="InstrCheck" value="Skin colour-normal"></td><td>Skin colour-normal</td></tr>
    <tr><td><input name="InstrCheck[]" type="checkbox" id="InstrCheck" value="Heart rhythm & rate normal"></td><td>Heart rhythm & rate normal </td></tr>
    <tr><td><input name="InstrCheck[]" type="checkbox" id="InstrCheck" value="No Oedema"></td><td>No Oedema </td></tr>
    </table>
    <textarea name="InstrCheck[]" id="InstrCheck" placeholder="set your own instruction">                          </textarea>
<input type="hidden" name="MM_insert" value="form1">
<input type="hidden" value="<?php echo $_GET['a'];?>" name="pat_id">
</form>

My problem is How can I insert checked options (could be more than one) AND textarea value (if entered) and insert all these input values into same column in DB but each input in “separate row”. I tried this code but not work insert nothing (empty cell):

<?php
$editFormAction = $_SERVER['PHP_SELF'];
    if (isset($_SERVER['QUERY_STRING'])) {
    $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
    }
    $pat_id = $_GET['a'];
    $Date = date("d-m-Y");
    $Time = date("H:i:s");
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
    foreach ($_POST['InstrCheck'] as $value) {
  $insertSQL = "INSERT INTO instruction (instName, instTime, instDate, pat_id) VALUES ('$value', '$Time', '$Date', '$pat_id')";
    }
  mysql_select_db($database_PPS, $PPS);
  $Result1 = mysql_query($insertSQL, $PPS) or die(mysql_error());


  $insertGoTo = "Patint_selection.php?a=$pat_id";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>
  • 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-23T17:29:45+00:00Added an answer on May 23, 2026 at 5:29 pm

    The empty cell that is being saved to the database is the value from your textarea.

    The reason your code is only saving the textarea is because it is the only query being executed by mysql_query. Your foreach loop is overwriting each query and the last value of $insertSQL is the textarea query. So, to fix you have to move the mysql_query inside the foreach loop and connect to the database before the loop starts.

    /** 
     *  Moving the mysql_query inside the loop requires you connect to the database 
     *  before the loop starts
     */
    mysql_select_db($database_PPS, $PPS);
    
    /** Move your mysql_query inside your foreach loop **/
    foreach ($_POST['InstrCheck'] as $value) {
        $insertSQL = "INSERT INTO instruction (instName, instTime, instDate, pat_id) VALUES ('$value', '$Time', '$Date', '$pat_id')";
    
        // Moved inside the loop...now this will run for each loop
        $Result1 = mysql_query($insertSQL, $PPS) or die(mysql_error());
    
    }
    

    The other answers are just as good and pointed out some things worth considering. I just want you to learn why your original code was wrong.

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

Sidebar

Related Questions

Here is a simple form I am using to send XML data in admin_xml.php
I'm using jQuery to post a form to a php file, simple script to
i want create one simple windows form ,it just contain Editcontrol(textbox),Static Edit(label),Button (Name of
Have a simple form (only extract fields here) but for some reason the JQserilization
I have a simple html form that submits information with POST function. But when
I'm trying to create a web form that contains checkboxes, among other input elements,
Here is the problem: I have a simple c# form I have a simple
Hey guys so, im doing this form with a input that will contain the
I have one simple User Registration form. It includes name, age, sex & city.
I'm probably missing something simple here, but I can't find the answer elsewhere. 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.