Welcome Guest, Not a member yet? Register   Sign In
Populating HTML Select Dropdown With Optgroups Based on Database Categories
#3

[eluser]Vheissu[/eluser]
[quote author="Dennis Rasmussen" date="1285616945"]How deep can a child (category) go?
You can read more about hierarchical data here: http://dev.mysql.com/tech-resources/arti...-data.html

Otherwise you can use a recursive method with a PHP array/function.[/quote]

Hi Dennis,

A category only goes one deep. There is always only going to be a few main categories, but no sub main categories.

This is for a band classifieds site I am building and the main categories are; Bands Seeking Musicians, Musicians Seeking Bands and Music Equipment for sale.

Both the musicians seeking and bands seeking will have children categories, but never any other main categories. So the categories would be; Bass Players, Lead Guitarists, Rhythm Guitarists, Vocalists..

I know I should be using nested foreach's, but I'm not sure if I can get away with using one MySQL query or I have to use two and the combine the results. Any examples you can provide me? I appreciate the help.

The example link you provided explains what I want to do perfectly, but I would prefer using as much PHP as possible to produce the results. I don't want to slow the site down with complicated SQL queries that could be done less intensively in PHP.


Messages In This Thread
Populating HTML Select Dropdown With Optgroups Based on Database Categories - by El Forum - 09-27-2010, 02:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB