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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:00:07+00:00 2026-05-24T06:00:07+00:00

I have an HTML form with a dynamic number of checkbox fields, all of

  • 0

I have an HTML form with a dynamic number of checkbox fields, all of which are encapsulated within a submit form. When the form is submitted, I want to loop through the values of each checkbox field with a PHP script. At the same time, I have to keep a certain ID associated with the checkbox field so that when I loop through each one in my script, I can use the ID to update the correct row in my database. Currently, I have:

<input checked="checked" name="attended_<?php echo($pid); ?>"

I’m just not sure how to go ahead and access all of the attended[] values from my PHP script (and keep the ID at the same time). Would I use a multidimensional array like the following?

<input checked="checked" name="attended[<?php echo($i); ?>][<?php echo($pid); ?>]; ?>"

I’d appreciate any help on this. 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-05-24T06:00:08+00:00Added an answer on May 24, 2026 at 6:00 am

    Usually when I create checkboxes I put an index in the name. This way you can loop through each checkbox in your submittion code.

    <input type="checkbox" name="cbGroup[1]" value="y" />
    <input type="checkbox" name="cbGroup[2]" value="y" />
    <input type="checkbox" name="cbGroup[3]" value="y" />
    

    and in your PHP

    foreach($_POST['cbGroup'] as $index=>$checkbox) {}
    

    You’ll want to make sure your $_POST[‘cbGroup’] is set though because it won’t be if the checkbox isn’t checked.

    Edit: Sorry, I should learn to read the question fully heh 🙂 I use multidimensional arrays in PHP with HTML inputs all the time and I think it’s the way I would go.

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

Sidebar

Related Questions

I have custom Question objects which I render into html form elements. I want
I have a html form for uploading a file, which is as follows: $uploadhtml
I have a HTML form containing checkboxes in the form of .. <input type=checkbox
I have an HTML form where the user can type in any number:5, 8,
I have a html form which have a select list box from which you
I have a HTML form with fields such as name, address, notes, etc. I
I have an array of checkboxes in a complex dynamic-html form. Whenever a user
I have an HTML form with plenty of inputs, most of which are optional.
I'm trying to submit a form which contains dynamic elements that were added to
I have a Rails nested form with the child fields that contain dynamic select

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.