Better Light User Gallery
Click on a Column Heading to Sort by that Heading
<% dim objST dim objConn, strSQL, strDSN Set objConn = server.CreateObject("ADODB.Connection") strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\~betterlightweb/public_html\usergallery\_private\gallery.mdb" objConn.Open strDSN strSQL = "select * from Users2" set objST = new clsSortableTable objST.Connection = objConn objST.SQL = strSQL objST.DefaultSort = "Company" objST.DisplayedFields = array("Company", "State", "Country", "Specialty") objST.PageSize = 10 objST.TableAttributes = "align=center border=2 bordercolor='#c4ded0' cellpadding=3 cellspacing=0" objST.HeaderRowAttributes = "valign='bottom'" objST.HeaderCellAttributes = "align=left class=tdHeader" objST.RowAttributes = "" objST.CellAttributes = "class='tdContent' nowrap align=left" objSt.FontTagAttributes = "class='tdContent'" objST.TextLink = true objST.LinkedColumnName = "Company" objST.FieldToAppendToLink = "UserID" objST.Link = "userGallery_detail.asp" objST.ImagePath = "images/" objST.AscImages = array("User ","St ","St " & vbcrlf 'display the headers writeHeaders() 'end table header if RS.EOF then Response.Write "" & vbcrlf Response.Write "" & vbcrlf Response.Write "" & vbcrlf else 'start records for i = intCurrentRecord to RS.PageSize if not RS.EOF then Response.Write "" & vbcrlf 'start record cells for j = 0 to intDisplayedFields ''''''''''''''''''''''''''''''''' ' if lcase(m_arrDisplayedFields(j)) = lcase(m_strLinkedColumnName) then Response.write "" else Response.write "" end if '''''''''''''''''''''''''''''''' ' next 'end cells Response.Write "" & vbcrlf RS.MoveNext end if next end if 'end records 'end table Response.Write "
" & vbcrlf Response.Write "There are no records." Response.Write "
 " & RS(m_arrDisplayedFields(j)) & " " & RS(m_arrDisplayedFields(j)) & "
" & vbcrlf 'write the navigation buttons Response.Write"
" writeNavButtons Response.Write"
" End Sub private sub Class_Terminate() if RS.State = &H00000001 then 'its open RS.Close end if set RS = nothing end sub '''CREATERECORDSET private sub createRecordset() with RS .CursorLocation=3 .Open m_strSQL & " order by " & replace(m_strSort,"desc"," desc"), m_objConn,3 if not rs.EOF then .PageSize = cint(m_intPageSize) intTotalPages = .PageCount intCurrentRecord = .AbsolutePosition .AbsolutePage = m_intCurrentPage intTotalRecords = .RecordCount intTotalFields = .Fields.Count else intTotalFields = 0 intTotalRecords = 0 intTotalPages = 0 intCurrentRecord = 0 end if end with end sub '''WRITEHEADERS private sub writeHeaders() Response.Write "" & vbcrlf for i = 0 to intDisplayedFields Response.Write "" & vbcrlf if instr(lcase(m_strSort),lcase(m_arrDisplayedFields(i))) then 'if we come across the current sort in the loop if instr(m_strSort, "desc")then 'if the sort is descending, write the link for ascending, but give a descending image Response.Write "" & m_arrDscImages(i) & "" & vbcrlf else Response.Write "" & m_arrAscImages(i) & "" & vbcrlf end if else 'if not the current sort Response.Write "" & m_arrPlainImages(i) & "" & vbcrlf end if Response.Write "" & vbcrlf next Response.Write "" end sub '''WRITENAVBUTTONS private sub writeNavButtons() if intTotalPages = 0 then intTotalPages = 1 select case cint(m_intCurrentPage) case cint(intTotalPages) 'last page if cint(intTotalPages) = 1 then 'its the only page strMoveFirst = m_arrNavString(0) '"" strMovePrevious = m_arrNavString(1) '"" strMoveNext = m_arrNavString(2) strMoveLast = m_arrNavString(3) '"" else strMoveFirst = ""& m_arrNavString(0) &"" strMovePrevious = ""& m_arrNavString(1) &"" strMoveNext = m_arrNavString(2) strMoveLast = m_arrNavString(3) '"" end if case 1 'first page strMoveFirst = m_arrNavString(0) '"" strMovePrevious = m_arrNavString(1) '"" strMoveNext = ""& m_arrNavString(2) &"" strMoveLast = ""& m_arrNavString(3) &"" case else strMoveFirst = ""& m_arrNavString(0) &"" strMovePrevious = ""& m_arrNavString(1) &"" strMoveNext = ""& m_arrNavString(2) &"" strMoveLast = ""& m_arrNavString(3) &"" end select with Response .Write strMoveFirst & " " .Write strMovePrevious .Write " " & m_intCurrentPage & " of " & intTotalPages & " " .Write strMoveNext & " " .Write strMoveLast end with end sub '''SETUPIMAGEARRAYS 'If the image arrays are empty Fill them with .gif images based on fieldnames private sub setUpImageArrays() if not isArray(m_arrPlainImages)or isnull(m_arrPlainImages) then redim m_arrPlainImages( intDisplayedFields ) for i = 0 to intDisplayedFields if cbool(m_blnTextLink) then m_arrPlainImages(i) = m_arrDisplayedFields(i) else m_arrPlainImages(i) = "" end if next end if if not isArray(m_arrAscImages) or isnull(m_arrAscImages) then redim m_arrAscImages( intDisplayedFields ) for i = 0 to intDisplayedFields if cbool(m_blnTextLink) then m_arrAscImages(i) = m_arrDisplayedFields(i) else m_arrAscImages(i) = "" end if next end if if not isArray(m_arrDscImages) or isnull(m_arrDscImages) then redim m_arrDscImages( intDisplayedFields ) for i = 0 to intDisplayedFields if cbool(m_blnTextLink) then m_arrDscImages(i) = m_arrDisplayedFields(i) else m_arrDscImages(i) = "" end if next end if if not isArray(m_arrNavString) or isNull(m_arrNavString) then redim m_arrNavString(3) m_arrNavString(0) = "" m_arrNavString(1) = "" m_arrNavString(2) = "" m_arrNavString(3) = "" end if end sub End Class %>