Home--> Articles -->Site Tools

Multi-levels sortings and conditional displays with ASP

Post By wsw5904239 on 2008-9-26 15:53:54  [Reads:343]


Multi-levels sortings and conditional displays with ASP has two exercises in one: we are going to learn to do some sortings to different levels on several fields at the same time, and then to display the data in a conditional way. The all in only 16 lines of code.

In our ASP page, we start with doing the sorting in the basis.

<% OBJdbConnection set = Server.CreateObject ("ADODB.Connection") OBJdbConnection.Open SQLQuery "mabase" = "SELECT * FROM table1 order by Name, First name, Age DESC" Set RS = OBJdbConnection.Execute(SQLQuery)% >

Then we display the data:

<% Do While NOT RS.EOF% > <% = rs ("Name")% > <% = rs ("First name")% > <% Yew rs ("Age") < 18 Then% > < IMG SRC = "pm.jpg" > <% Else% > <% = rs ("Age")% > years <% End Yew% > < br > <% rs.movenext Loop% >

And as usual, one doesn't forget to close the connection:

<% rs.close set rs = nothing% >

Sponsor Sites

Free Articles


Categories