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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:48:55+00:00 2026-05-29T11:48:55+00:00

I have a form with multiple rows of checkboxes, each with a specific id,

  • 0

I have a form with multiple rows of checkboxes, each with a specific id, that are being displayed using a foreach loop.

How do you grab the $_POST info from something like that? I think it is like this somehow $_POST[][], like a sub-array, but I cant figure out how to set it up:

foreach($stakholderArray as $currentEntry) {
    print "<tr class='$bgcolor'>";
    print "<td class='left'>$currentEntry[org]</td>";

    if($currentEntry['dataFound']) {  
        //if data was found for current stakeholder, display it
        print ($currentEntry['Partner']) ? '<td><input type ="checkbox" checked ="checked" /></td>' : '<td><input type ="checkbox"  /></td>';
        print ($currentEntry['Agreement']) ? '<td><input type ="checkbox" checked ="checked" /></td>' : '<td><input type ="checkbox"  /></td>';
        print ($currentEntry['Train']) ? '<td><input type ="checkbox" checked ="checked" /></td>'  : '<td><input type ="checkbox"  /></td>';
        print ($currentEntry['Meet'])  ? '<td><input type ="checkbox" checked ="checked" /></td>' : '<td><input type ="checkbox"  /></td>';
    }
    else {  //else...no stakeholder data, display empty columns
        print "<td><input type ='checkbox'/></td><td><input type ='checkbox'/></td><td><input type ='checkbox'/></td><td><input type ='checkbox'/></td><td><input type ='checkbox'/></td>";
        print "</tr>";
    }## Heading ##
  • 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-29T11:48:58+00:00Added an answer on May 29, 2026 at 11:48 am

    it’s somewhat related to a question i answered before: POST an array from an HTML form without javascript

    • encase them in a form
    • give them an “array” name
    • they end up as an array during post when submitted

    related items should have like this: name="item[collection name][collection name][]" – note the first indices pertaining the set (for easy location), and the empty index meaning in that set, there’s an array (instead of single value). so for your check boxes:

    <input type="checkbox" name="answers[set1][]" value="apple" />   //imagine checked
    <input type="checkbox" name="answers[set1][]" value="orange" />  //imagine checked
    <input type="checkbox" name="answers[set1][]" value="grape" />
    <input type="checkbox" name="answers[set2][]" value="airplane" />   //imagine checked
    <input type="checkbox" name="answers[set2][]" value="train" />  //imagine checked
    <input type="checkbox" name="answers[set2][]" value="boat" />
    <input type="checkbox" name="answers[solo]" value="boar" /> //single type value. note that there is no [] in the end
    

    end up like this in the request array (like say POST):

    $_POST[] = array(
        'answers' => array(
            'set1' => array('apple','orange'),   //unchecked items won't be included
            'set2' => array('airplane','train'), //unchecked items won't be included
            'solo' => 'boar'
        )
    );
    

    <table>
        <?php foreach($stakeholderArray as $stakeholder): ?>
        <tr>
    
        <?php 
    
            //declare so these exist regardless of data
            $partner   = '';
            $agreement = '';
            $train     = '';
            $meet      = '';
    
            //if we have data, mark the boxes accordingly
            if($stakeholder['dataFound']){
    
                $checked = 'checked ="checked"';
    
                //mark as checked or blank
                $partner   = ($stakeholder['Partner'])   ? $checked: '';
                $agreement = ($stakeholder['Agreement']) ? $checked: '';
                $train     = ($stakeholder['Train'])     ? $checked: '';
                $meet      = ($stakeholder['Meet'])      ? $checked: '';
    
            }
        ?>
    
           <td><input value='partner' name="stake[<?= $stakeholder ?>][partner]" type ="checkbox" <?= $partner ?> /></td>
           <td><input value='agreement' name="stake[<?= $stakeholder ?>][agreement]" type ="checkbox" <?= $agreement ?> /></td>
           <td><input value='train' name="stake[<?= $stakeholder ?>][train]" type ="checkbox" <?= $train ?> /></td>
           <td><input value='meet' name="stake[<?= $stakeholder ?>][meet]" type ="checkbox" <?= $meet ?> /></td>
    
        </tr>
        <?php endforeach; ?>
    </table>
    

    they should end up like:

    $_POST[] = array(
        'stakeholder1' => array(
            'partner'=> 'partner',
            'agreement'=> 'agreement',
            'train'=> 'train',
            'meet'=> 'meet'
        ),
        'stakeholder2' => array(
            'partner'=> 'partner',
            'agreement'=> 'agreement',
            'train'=> 'train',
            'meet'=> 'meet'
        ),
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Morning All, I have a form that I am using to add multiple rows
I have a table with multiple rows. Each row is a form. I want
I have a table with multiple rows which contain form inputs (checkboxes, text, dropdowns).
i have a form that has a multiple select drop down. a user can
I have an HTML form that needs multiple submit buttons, like this: <input type=submit
I have a form that enables a user to update multiple alert rules records
I have a report that is basically a form with multiple empty fields and
I have a form where at some point you can add multiple rows of
If I have a form with fields like this. THERE WILL BE MULTIPLE ROWS
I have a form with multiple rows of text boxes. I use jquery .show()

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.