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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:44:22+00:00 2026-05-25T02:44:22+00:00

I would like to save multiple checkbox(PHP and JQuery) in to MYSQL database. Example

  • 0

I would like to save multiple checkbox(PHP and JQuery) in to MYSQL database.
Example table test there are 4 fields. Column A, NAME, C AND D.

After I clicked save it will be saved to those table;

jQuery code:

$(document).ready(function() {          
    $("#btnsave").click(function() {
        var test = [];

        $("input[name='aa[]']:checked").each(function() {
            test.push($(this).val());
        });                   

        alert(test);    
    });
});

function toggleCheckeda(status) {
    $(".chkaa").each( function() {
        $(this).attr("checked", status);
    })          
}

function toggleCheckedb(status) {
    $(".chkab").each( function() {
        $(this).attr("checked", status);
    })          
}

function toggleCheckedc(status) {
    $(".chkac").each( function() {
        $(this).attr("checked",status);
    })          
}

PHP code:

$db->Connect(); 
$stmt = $db->ExecData("select id,A,name,C,D from tbl_check");
<form id="frm1" name="frm1">

    <table>    
        <tr>
         <td>
          <input type="checkbox" value="" onclick="toggleCheckeda(this.checked)">
         </td>
         <td></td>
         <td>
          <input type="checkbox" value="" onclick="toggleCheckedb(this.checked)">
         </td>
         <td>
          <input type="checkbox" value="" onclick="toggleCheckedc(this.checked)">
         </td>
        </tr>

        <tr>
            <th>
                A
            </th>
            <th>
                Name
            </th>
            <th>
                C
            </th>
            <th>
                D
            </th>
        </tr>
        <?php while ($row = $db->GetRow($stmt)){ ?>
        <tr>
            <td>
                <input type="checkbox" class="chkaa" name="aa[]" id="chk[]" value="a<?php echo $row["id"]; ?>" />
            </td>
            <td>
               <?php echo $row["name"]; ?>
            </td>
            <td>
           <input type="checkbox" class="chkab"  name="cc[]" id="chk[]" value="c<?php echo $row["id"]; ?>" />
            </td>
            <td>
                <input type="checkbox" class="chkac"  name="dd[]"  id="chk[]" value="d<?php echo $row["id"]; ?>" />
            </td>

        </tr>
       <?php } ?>
    </table>
   <input type="button" id="btnsave" name="btnsave" value="save" />
 </form>
  • 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-25T02:44:23+00:00Added an answer on May 25, 2026 at 2:44 am

    I am not sure what exactly your question is, because in the title you said you need to save multiple checkboxes via jQuery and PHP. and in your PHP code you are selecting it. well you have made things quite complicated. assuming you want to save checkboxes value via jQuery to PHP.

    you need AJAX to save the values of checkboxes via jQuery. take for example see the html form below.

    <form action="" method="post" id="save-something"/>
        <input type="checkbox" name="id[]" value="1"/>One
        <input type="checkbox" name="id[]" value="2"/>Two
        <input type="checkbox" name="id[]" value="3"/>Three
        <input type="checkbox" name="id[]" value="4"/>Four
        <input type="checkbox" name="id[]" value="5"/>Five
        <input type="checkbox" name="id[]" value="6"/>Six
        <input type="checkbox" name="id[]" value="7"/>Seven
        <button type="submit" name="save">Save</button>
    </form>
    

    here is the jQuery Code.

    $('#save-something').click(function(e){
        e.preventDefault();
        var formData = $(this).serialize();
        $.ajax({
            type: 'POST',
            url:  'process.php',
            data: formData,
            success: function(msg){
                alert('Sucessfully Saved');
            }
        });
    });
    

    and in process.php you can do something like.

    if(isset($_POST['submit'])) {
        if(!empty($_POST['id'])) {
            $query = 'Your Insert Query or PHP logic goes here';
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to update multiple records in a MySQL table using a single
My Flash movie would like communicate with MySQL server to fetch and save data
I would like to save the programs settings every time the user exits the
I would like to save data in cookies (user name, email address, etc...) but
I would like to save and restore the state of a WinForms Form ,
Scenario I would like to save images with alpha transparency as .png and images
I have an ASP.Net form and i would like to save it into a
I've made some experimental code that I would like to save in the repository,
I would like to know the best way to save an image from a
I would like to be able to fetch a web page's html and save

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.