Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grouping

Status
Not open for further replies.

Ouch

Programmer
Jul 17, 2001
159
GB
does anyone know who i could group on an asp page.

eg I HAVE

level title
1 TEST1
1 TEST2
1 TEST3
1 TEST4
2 TEST1
2 TEST2
2 TEST3
2 TEST4

I want

Level 1
TEST1
TEST2
TEST3
TEST4
Level 2
TEST1
TEST2
TEST3
TEST4

help would be gratly appreciated
here is my code so far

<%
DO WHILE NOT rsall.EOF
response.write(&quot;<tr>&quot;)
%>
<td height=&quot;18&quot; width=&quot;34&quot;>
</td>
<td height=&quot;18&quot; width=&quot;1&quot;>
<%=rsall(&quot;clevel&quot;)%>
</td>
<td height=&quot;18&quot; width=&quot;1199&quot;>
<p>
<font face=&quot;Arial&quot;><a href=&quot; </td>
<% rsall.movenext
loop

set rsall = nothing
%>
 
Simple, just split up the select statements and loops so it only calls the tests for each particular level.


&quot;SELECT * FROM database WHERE Level=1&quot;

the second:

&quot;SELECT * FROM database WHERE Level=2&quot;

and so on.

Hope this helps :) Nick (Web Designer)


nick@retrographics.co.uk
 
the trouble with that is i have 200 or so levels

and the levels are pulled from the database
 
i found an article that does exactly what i want

<table border=0>
<!--#include file=&quot;DSNConnection.asp&quot;-->

<%
tablename =&quot;qry_all_courses&quot;
sqlstr = &quot;SELECT * FROM &quot; & tablename & &quot; ORDER BY clevel, ctitle&quot;
set rsall = dbConn.execute(sqlStr)
%>
<%

sPrevParent = &quot;&quot;
sParent = &quot;&quot;
while not rsall.EOF
sPrevParent = sParent
sParent = rsall(&quot;clevel&quot;)
Response.Write &quot;<tr>&quot;
if strcomp(sPrevParent, sParent) <> 0 then
Response.Write &quot;<td>&quot; & sParent & &quot;</td>&quot; & vbCRLF

else
Response.Write &quot;<td>&nbsp;</td>&quot; & vbCRLF
end if
Response.Write &quot;<td>&quot; & rsall(&quot;ctitle&quot;) & &quot;</td></tr>&quot; & vbCRLF
rsall.MoveNext
wend
rsall.Close
set rsall.ActiveConnection = nothing
set rsall = nothing
%>
</table>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top