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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:00:01+00:00 2026-06-04T10:00:01+00:00

I am busy now making a webshop with different categories, and also different parent

  • 0

I am busy now making a webshop with different categories, and also different parent id’s.
My database structure is as follows:

id – name – parentid:

1 – games – 0

2 – movies – 0

3 – type – 1

4 – type – 2

5 – action – 3

6 – history – 4

Now in the admin part when i want to add a category, i want to show in a dropdown all my categories, but i want the parent and the childs separated. Is there an easy way to do this?

Greetings Eric

  • 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-04T10:00:05+00:00Added an answer on June 4, 2026 at 10:00 am

    I’m not sure what you mean by “want the parent ids and child ids separated.” Understand that the elements in a select are nothing more than a display value and a data value, and the data value will be what gets sent to the server along with the field name.

    So the select can’t really distinguish between multiple kinds of data values. Each option can’t have multiple IDs, for example. All you could do is format your display value to include IDs (such as you have with “1 – games – 0” and such), and decide which data value should be the value for that option in the select.

    One thing you can do is group option elements, using the optgroup tag. Something like this:

    <select name="myOptions">
      <optgroup label="Category 1">
        <option value="1">First Choice</option>
        <option value="2">Second Choice</option>
        <option value="3">Third Choice</option>
      </optgroup>
      <optgroup label="Category 2">
        <option value="4">Fourth Choice</option>
        <option value="5">Fifth Choice</option>
      </optgroup>
      <optgroup label="Category 3">
        <option value="6">Sixth Choice</option>
        <option value="7">Seventh Choice</option>
      </optgroup>
    </select>
    

    In validation, the browser shouldn’t allow the user to select a group, they would have to select an actual option. So you shouldn’t have to worry about that. This does present some additional flexibility in displaying your values more hierarchically. Understand, however, that only one level of option nesting is allowed in this case. (So an optgroup can’t contain another optgroup.)

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

Sidebar

Related Questions

I'm busy on making a Business Logic Layer. Now I had a problem since
A project I am busy on now requires many different kinds of stats, most
I'm busy writing a application that refreshes a IFrame completely using javascript, now my
I'm busy with a little topdown shooter in XNA. Now I have a little
I'm busy making a CMS using MVC3. I want to test the current build
I'm trying to add a progress meter, or other I'm busy right now notification
I've been busy with C# 4.0 generics, and now I basically want to do
I've been busy with C# 4.0 generics, and now I basically want to do
I'm busy developing an application where users can search within multiple table, now I'm
I'm busy changing from normal mysql_queries to prepared statements, now I found a function

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.