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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:45:53+00:00 2026-06-17T14:45:53+00:00

I have created a form to display main categories and its subcategories. Everything in

  • 0

I have created a form to display main categories and its subcategories. Everything in this form is creating dynamically. Why I use this form is to get subcategory values which selected from users. Here I use checkboxes for this purpose.

This is PHP I use for this..

echo "<input type='checkbox' value='{cId:sId}' name='subcategory{$cId}[]' />{$sName}";

Then generating HTML something like this…

<h3>Main Category 01 
    <input type='checkbox' value='3:4' name='subcategory3[]' />sub category
    <input type='checkbox' value='3:6' name='subcategory3[]' />sub category

<h3>Main Category 02 
    <input type='checkbox' value='4:6' name='subcategory4[]' />sub category
    <input type='checkbox' value='4:2' name='subcategory4[]' />sub category

<h3>Main Category 01 
    <input type='checkbox' value='5:8' name='subcategory5[]' />sub category
    <input type='checkbox' value='5:4' name='subcategory5[]' />sub category

In this case you can see subcategory names generating dynamically. (subcategory3, subcategory4, subcategory5). Those values also may change according to the selected main category. Here I would like to know how I validate subcategory values with ISSET(). Because I dont know to detect what are values come from $_POST array..

Can someone help me out..

Thank You.

  • 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-17T14:45:54+00:00Added an answer on June 17, 2026 at 2:45 pm

    With that naming convention, you will have to parse the number out of the checkbox name:

    foreach($_POST as $key => $value)
    {
        if(strpos($key, 'subcategory') === 0 && is_array($value))
        {
            $subCategoryNumber = substr($key, 11);
    
            // loop over the values for this subcategory array:
            foreach($value as $checkboxValue)
            {
                echo 'subcategory checked: ' . $subCategoryNumber . ', value: ' . $checkboxValue;
            }
        }
    }
    

    Instead of that, you could add a dimension to your array and use:

    <input type='checkbox' value='3:4' name='subcategory[3][]' />sub category
    
    <input type='checkbox' value='4:6' name='subcategory[4][]' />sub category
    
    <input type='checkbox' value='5:8' name='subcategory[5][]' />sub category
    

    This would mean you can access them in $_POST['subcategory'] as an array:

    foreach($_POST['subcategory'] as $key => $checkboxList)
    {
        foreach($checkboxList as $checkboxValue)
        {
            echo 'subcategory checked: ' . $key . ', value: ' . $checkboxValue;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an adopter to display images thumbnail of video form the specific
I have a main windows form (MainForm.cs) where I created an instance of Customer
I have created a Delphi 7 application. The main form is a TForm object
I have created one application in which Main Form Calls Sub Form on FormShow
Hi I have created a zend_form_element_submit. Now i want to display a confirmation message
I have created a form that contains fields used to accept a floating value
I have created a form <form name=form1 method=post> <textarea rows=5 cols=20 name=ta1></textarea> <input type=submit
I have created a form with knockout that will allow the ability to give
I have created a form to upload a a newsletter into the database. I'm
I have created a form that is used for both adding and editing a

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.