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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:33:53+00:00 2026-06-18T01:33:53+00:00

I have an html page where I collect an array of values from checkboxes

  • 0

I have an html page where I collect an array of values from checkboxes to insert in a database. The html page posts to a PHP page that collects the data and then stores in the database.

For each value, there are a few other fields I would like to include that are the same for all the values such as time entered. I can easily convert the captured array into a comma delimited list using implode. I use such a comma delimited list of ids to update and delete records. However, when I want to insert them, MYSQL does not seem to allow you to use a comma delimited list. My question is, what is the easiest way to insert records, one for each value in the c comma delimited list, without using a loop.

html page

<input type="checkbox" name="var[]" value=1>
<input type="checkbox" name="var{}" value=2>

PHP page

$vars = $_POST['var'];

This gives me an array that I can convert to a comma delimited list using implode.

To delete, I can go

$sql = "DELETE * from table WHERE id in '$vars'";

To update I can go

$sql = "UPDATE table, WHERE id in '$vars'";

But there does not seem to be an equivalent for Insert.

Following would work:

$sql = "INSERT into table (var, timeentered) values (1,now()) (2,now())";

However, that’s not how I have my data. what I would like to do is something like

$sql = "INSERT into table (var,timeentered) values($vars), now()" but of course that doesn’t work.

Do I have to convert my nice comma delimited list that works so well for update and delete into something that looks like (1,now) (2, now()) for inserting or is there an alternative?

Thanks for any suggestions.

  • 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-18T01:33:54+00:00Added an answer on June 18, 2026 at 1:33 am

    Unfortunately you have to build whole query by yourself:

    $sql ="insert into table (var, timeentered) values ";
    $sql .= "(".implode(", now()), (", $vars).")";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP page that will collect mp3 links from downloads.nl. The result
I have a html page that after ajax call show a lot of data
I have a html page that allows users to submit a file. Below is
I have an html page that open a popup window when the page loads.
I have an HTML page that contains some filenames that i want to download
Say I have an HTML form like this to collect an email from a
What's the best way to collect data from a form using checkboxes so it's
i have html page with link like /with_us.php?page=digit and out.php?i=digit . how can i
I am using jsp for scripting. I have a page where I collect data
I have a wizard style interface where I need to collect data from users.

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.