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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:27:07+00:00 2026-06-15T17:27:07+00:00

I am having a bit of a problem, i am trying to store data

  • 0

I am having a bit of a problem, i am trying to store data with checkboxes, but i cant seem to figur it out. Right now i have made a script that can show multiple checkboxes all with the same name. So my question is now, how do i make the page where the data is sended to making them seperated? like:

<input type='checkbox' checked name='cpu-link[]' value='1' />
<input type='checkbox' checked name='cpu-link[]' value='2' />
<input type='checkbox' checked name='cpu-link[]' value='3' />

how can i get it stored for each checkbox in a new row in the mysql database?
so it would be like:

  1. Data 1
  2. Data 2
  3. Data 3

And then i have a related qestion, how do i make so that the checkboxes that is not checked will get removed if they already is in the database.
so if it is like this:

<input type='checkbox' checked name='cpu-link[]' value='1' />
<input type='checkbox' name='cpu-link[]' value='2' />
<input type='checkbox' name='cpu-link[]' value='3' />

Then the row with the id 2 and 3 will get removed but the row with id 1 will get created or just stay if it already is in the database.

It is all a kind of a link between 2 tables.
I have a table with pc’s in, and a table with hardware in.
then i have the table with the links in, so if i choose a hardware that needs to bee in a machine, it will create a row in the link table so that when i display the pc, it shows with that hardware oppotionity.

sorry for my bad english.
Thank You in Advance

  • 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-15T17:27:08+00:00Added an answer on June 15, 2026 at 5:27 pm
    $all_cpu_links = array(); // here is your array with all possible values of cpu-link
    $previously_checked = array(); // array of values that are already in your database
    $to_be_removed = array();
    $to_be_inserted = array();
    
    // It is better to use here here a prepared statement by the way
    foreach ($_POST['cpu-link'] as $cpu_link)
    {
        if (!in_array($cpu_link, $previously_checked))
        {
            // validate $cpu_link here
            mysql_query("INSERT INTO table (`cpu_link`) VALUES (".$cpu_link.");");
        }
    
    }
    
    foreach ($all_cpu_links as $cpu_link)
    {
        if (!in_array($cpu_link, $_POST['cpu-link']) && in_array($cpu_link, $previously_checked))
            $to_be_removed[] = $cpu_link;
    }
    
    mysql_query("DELETE FROM table WHERE `cpu_links` IN (".implode(' ,', $to_be_removed).");");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to script Dice's Coefficient, but I'm having a bit of a problem
I'm having a bit of a problem trying to import data from a CSV
I am having a bit of a problem, I am trying to get a
I'm having a bit of a problem figuring out how to get the X/Y
I'm having a bit of a problem trying to get touchesBegan to respond to
I'm having a bit of a problem. I am trying to create an IRC
Coming from Win32, I am having bit of an issue or a problem trying
learning python currently and having a bit of a problem. I'm trying to take
I'm having a little bit of problem with my derived class. Basically I have
Hi I'm having a bit of a problem with my code I'm trying to

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.