Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gilgamesh
Starting Member
14 Posts |
Posted - 2001-11-05 : 10:17:16
|
I am writing an address book app. The problem is that I need to display the contents of the SQL database alphabetically but with headings (see below) I can't work out the best way to do it. Below is the code I am using at the moment - but I get a feeling there is a much better way of doing it.Many thanks in advance!OliverAColin AbrahamSteven AdamsBAndrew Binkley...------------------------------------------------------------------------------------------------------------------------------------------------------------------------'i am using a SELECT * FROM...<%ARRAlphabet = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")i = 0do while i < 26%><tr><td colspan=4><font size="4"><%=uCase(ArrAlphabet(i))%></font></td></tr><% recordset.moveFirst do while not recordset.eofif request.QueryString("sort") = "last" then sLetter = recordset.Fields("RecLastName") sLetter = left(sLetter, 1) sLetter = lcase(sLetter) else sLetter = recordset.Fields("RecFirstName") sLetter = left(sLetter, 1) sLetter = lcase(sLetter) end if if sLetter = ArrAlphabet(i) then%> <tr> <td></td> <td><%=recordset.Fields("RecFirstName")%></td> <td><%=recordset.Fields("RecLastName")%></td> <td><%=recordset.Fields("RecEmail")%></td></tr> <% else end if recordset.movenext loop i = i + 1 loop------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
|
|
|
|