Question : populating select limited to one category and its subcategories

I need to limit the entries in this select to being only CatID=211 and all of its subcats which have a CatParent='211'. Currently, it lists everything in the table. I'm still a rank newbie at this.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
$selcats="SELECT * from mcs_content_cat ORDER BY CatName ASC";
    $selcats2=mysql_query($selcats) or die("Could not get categories");
    while($selcats3=mysql_fetch_array($getcats2))
    {
    }
	$selcat="SELECT * from mcs_content_cat ORDER BY CatName ASC";
    $selcat2=mysql_query($selcat) or die("Could not select CatID"); 
	traverse(0,0,$selcat2);
	echo $selcat2;



Traverse Function:

function traverse($root, $depth, $sql)
{
     $row=0;
     $rows = mysql_num_rows($sql);
   
     while ($row < $rows)
     {
          mysql_data_seek($sql,$row);
          $acat = mysql_fetch_array($sql);
          if ($acat['CatParent'] == $root)
          {
               print "<option value='" . $acat['CatID'] . "'>";
               $j=0;
               while ($j<$depth)
               {    
                     print "&nbsp;&nbsp;";
                    $j++;
               }
               if($depth>0)
               {
                 print "-";
               }
               print $acat['CatName'] . "</option>";
               traverse($acat['CatID'], $depth+1,$sql);
          }
          $row++;
     }
}

Answer : populating select limited to one category and its subcategories

Random Solutions  
 
programming4us programming4us