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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:50:45+00:00 2026-06-13T07:50:45+00:00

I have a form as below which allows user to select different collar types.

  • 0

I have a form as below which allows user to select different collar types. Each checkbox has a collar id which will be submitted when the form is submitted.

collar types

Assume that user selected 1st three collars. It would look like this.

collar types

Then what I do is add these three collar to my collars table using an insert statement. After that If user wants, he can uncheck the collar types or add new.

Assume that user unchecked the 2nd type as below.

collar types

Now the particular row which refer to the 2nd collar type must be deleted from the table. Below images shows the table structure.

enter image description here

Now my problem is When the form is submitted if user has made any changes(checked new checkbox or unchecked any) How can I Insert or delete a row? Do I have to write SELECT statement for each checkbox and see whether that collar id exists?

Help me out with the logic because I’m able to build the code myself according to a given logic.

Thanks

  • 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-13T07:50:46+00:00Added an answer on June 13, 2026 at 7:50 am

    I think there are 2 solutions:

    1. You have to SELECT all ids from your table and verify if the checkboxes are selected or not:

      $array = array();
      $sql = mysql_query("SELECT collor_id FROM my_table WHERE product_id='x'");
      while($row = mysql_fetch_array($sql)) {
          array_push($array, $row['collor_id']);
      }
      
      if(count($_POST['my_collors']) > 0) {
          foreach($_POST['my_collors'] as $value) {
              if(!in_array($value, $array)) {
                   // insert it into db
                   // unset the array value for this collor id
              } else {
               // unset the array value for this collor id
              }
          }
      }
      
      // foreach remained array value delete them from the db
      
    2. You can DELETE * the entries from the table for the selected product and then INSERT the new values

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

Sidebar

Related Questions

I have a php form which allows the user to provide a reference number
I have this form tag below where the form submits to itself which I
In the dialog form below, I have 2 buttons: Save & Cancel. When user
I have created an application which allows the user to find the nearest hotels.
i have my code(html/javascript) here which allows user to input the size and color
I have script which allows the user to choose an image and write something
We have HTML form which will allow french alphabets. So we have added validation
Scenario: I have a WPF desktop application which will be distributed on different machines
I have a form that allows the user to perform a myriad of searches.
I have the form like below <form id=myform class=form-horizontal class=collapse in> <fieldset> <!-- form

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.