hi - <BR><BR>having a confusing problem... trying to get a page to come out categorized when i don&#039;t know where the categories end... here&#039;s a sample db:<BR><BR>cat_id parent_no<BR>______ _________<BR>100 0<BR>101 100<BR>102 100<BR>103 100<BR>104 100<BR>105 104<BR>106 104<BR>107 104<BR>108 100<BR><BR>Desired Result:<BR><BR>100<BR> 101<BR> 102<BR> 103<BR> 104<BR> 105<BR> 106<BR> 107<BR> 108<BR><BR>The problem I get 108. It won&#039;t categorize right when I get to a level where I have to go back. I can&#039;t figure out how to go back.. Below is my code... ANY hint will help!! thanks!!!<BR><BR><BR><BR>here&#039;s the code i have so far, but it doesn&#039;t work right...<BR><BR>Sub ProcessNode(NodeID)<BR> Set rs2 = Server.CreateObject("ADODB.RecordSet")<BR> strQ2 = "SELECT * FROM cat WHERE parent_no=" & NodeID & " ORDER BY cat_id, parent_no"<BR><BR> rs2.Open strQ2, ObjConnect, adOpenStatic, adLockReadOnly, adCmdText<BR> <BR> flag2=0<BR> <BR> While NOT rs2.EOF<BR> if rs2("parent_no") = prev then<BR> count = count<BR> elseif ((rs2("parent_no")) &#060; prev) then<BR> count = ((flag2)*5)<BR> elseif ((rs2("parent_no")) &#062; prev) then<BR> bcount = bcount + 1<BR> count = count + 5 <BR> end if<BR> <BR> for i = 1 to count<BR> response.write "&nbsp;"<BR> next<BR><BR> response.write rs2("cat_name_tx") & "<BR>"<BR> prev = rs2("parent_no") <BR> temp = rs2("cat_id")<BR> <BR> ProcessNode(temp)<BR> flag2 = flag2 + 1<BR><BR> if (flag2&#062;1) then<BR> flag = count * flag2<BR> else<BR> flag = count<BR> end if<BR><BR> rs2.movenext<BR> Wend<BR>End Sub<BR><BR><BR>Set rs1 = Server.CreateObject("ADODB.RecordSet")<BR>strQ1 = "SELECT * FROM cat WHERE parent_no=0 ORDER BY cat_id"<BR>rs1.Open strQ1, ObjConnect, adOpenStatic, adLockReadOnly, adCmdText<BR><BR>While NOT rs1.EOF<BR> <BR> response.write "&#060;b&#062;" & rs1("cat_name_tx") & "&#060;/b&#062;<BR>"<BR> count=0<BR> prev = 0<BR> bcount=0<BR> flag = 0<BR> flag2 = 0<BR> call ProcessNode(rs1("cat_id"))<BR><BR> rs1.movenext<BR>Wend<BR><BR>