I've gotten this far with my code. I can't seem to get the 3rd level subcategories to go underneath their prospective category above them in the heirarchy. They go to the bottom of the dropdown list. 2nd level cat's line up fine. Could you please assist in what i need to change/add to make that happen?
<?php
/* select those with no parent so we have all categories first
and place in an array */
$sql = "select catid,catname from spec_categories where subcatid is null ORDER BY catname ASC";
$res = mysql_query($sql);
while (list($id, $d) = mysql_fetch_row($res)) {
$options[$id][0] = "<option value=\"$id\">$d</option>";
}
/* now get subcats and append them to the cats already in our array */
$sql = "select subcatid,catname,catid from spec_categories where subcatid is not null ORDER BY catname ASC";
$res = mysql_query($sql);
while (list($pa, $d, $id) = mysql_fetch_row($res)) {
$options[$pa][] = "<option value=\"$id\"> $d</option>";
}
/* build options */
echo "<select name=\"catid\"><br>\n";
foreach ($options as $opts) {
foreach($opts as $op) {
echo $op;
}
}
echo "</select><br>"; ?>