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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:44:13+00:00 2026-06-17T12:44:13+00:00

I’ve been working on this and searching the Web and coming up empty for

  • 0

I’ve been working on this and searching the Web and coming up empty for the better part of two days. With a lot of sweat, I can insert one checkboxed value into a DB; however, if I check more boxes, it will still only insert one value.

Here is my code I’m using on input user page (with form tags excluded):

  <input type="checkbox" name="skills[]" value="1"> ActionScript<br />
  <input type="checkbox" name="skills[]" value="2"> AppleScript <br />

Now I’m grabbing two session variables to make link the selected skill to the user who is logged on:

  $skills = $_POST['skills'];
  $id = $_SESSION['Ind_ID'];

Here is the code that there is some small error in:

for ($i=0; $i<sizeof($skills);$i++) {
    // echo $skills[$i];
    $query= "INSERT INTO individual_skills(Skills_ID,Ind_ID) VALUES (" .$skills[$i]. ",
            ".$_SESSION['Ind_ID'].")";
 }

With my echo $skills[$i] I can see that I am looping and can display as many user inputs to the screen; so, that is the good news.

The issue is I can’t get it to insert more than one value into a DB. I can do one value at a time; but, no more than one.

It seems my query is pretty close. It works perfect if I choose to select only one checkbox; however, if I select more than one, it only inputs the last value (so, if I have 10 values selected, it will insert the last value into the DB).

Any help, much appreciated.

I’m using PHP and MySQLi

UPDATED BASED ON FEEDBACK FOR LOOP
Here is the updated loop. I have the query outside the loop, and now trying to APPEND to my initial query. Error says something is wrong with the syntax of the query.

$query= "INSERT INTO individual_skills(Skills_ID,Ind_ID) VALUES (" .$skills[$i]. ",
                                                        ".$_SESSION['Ind_ID'].")";

  for ($i=0; $i<sizeof($skills);$i++) {
  //echo $skills[$i];
  $query.= " VALUES (" .$skills[$i]. ",".$_SESSION['Ind_ID'].")";
  }
  • 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-17T12:44:14+00:00Added an answer on June 17, 2026 at 12:44 pm

    Think about what your code is doing. Each loop, you’re redefining the $query variable, so that when you get to the end, the final value of $query will be the last think you checked.

    If you still want to use the same loop logic that you have written, which is probably not the most efficient way, then you’d have to execute the query each time within the loop, so that each query you write will be executed.

    More precisely, the confusion seems to be stemming from the fact you haven’t quite discovered the difference between assigning a value to a variable and passing a variable to a function for execution.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.