PDA

View Full Version : optgroup and options


Acers
06-26-2006, 04:12 AM
hi,
just need a bit of help to get the optgroup working properly(i got something up with two while loops but not getting this properly and its very dirty :P)

So any suggestions or pseudo code would be nice.


Case in point is this
i have two tables

title{
titleid
name
etc etc)

and another
pnames{
id
titleid -> back assoc with the title table above
pname
}

what i wanna build is something like this


TITLE 1
pname 1
pname 2
pname 3
TITLE 4
pname 5
pname 6


The TITLE part is the optgroup and the parts under it are the options.

Note the pnames are shown for that title group based on the titleid field(so all the pnames that have titleid as of TITLE 1 will fall into its optgroup. I have been trying to do with double while loops Adding the clause "ORDER BY titleid DESC" to both to get proper ordering and then trying some associations.


EDIT: Ok got it working nicely after a bit of trial and error.. thanks anyway :D

sabret00the
06-29-2006, 08:16 PM
did you do it by grouping in the sql query?