<%@ Language=VBScript %> <% gend = CStr(Request.QueryString("gender")) Dim iPageSize 'How many records To show Dim iRecCurrent ' The page we want To show Dim sSQL 'SQL command To execute Dim RecSet 'The ADODB recordset object Dim I 'Standard looping var Dim iRecEnd ' Last Record Dim iRecMax ' Max of record Loop Dim J ' Loop variabel Dim iRecNext ' Var of Next record To start at Dim iRecPrev ' Var of Previous record Dim sGender ' Var For displaying whether Women's or Men's race Dim iNumPage ' Number of pages ' Get parameters iPageSize = 20 ' Retrieve page to show or default to 0 If Request.QueryString("page") = "" Then iRecCurrent = 0 ' First Record Else iRecCurrent = CInt(Request.QueryString("page")) End If ' Assign value to race If gend = "Male" Then sGender = "Men's" Else sGender = "Women's" End If ' SQL statement sSQL = "SELECT * FROM 5KResults WHERE Gender='" sSQL = sSQL & gend & "' ORDER BY Time" Set RecSet = Server.CreateObject("ADODB.Recordset") RecSet.Open sSQL,"DSN=chiledadsn",adOpenForwardOnly,adLockReadOnly ' Get the count of the records Do While Not RecSet.EOF J = J + 1 RecSet.MoveNext Loop iRecEnd = J -1 ' Get the number of pages iNumPage = CInt(iRecEnd/iPageSize) ' If the request page falls outside the ' acceptable range, ' give them the closest match (0 or max) ' If iRecCurrent > iRecEnd Then iRecCurrent = iRecEnd If iRecCurrent < 0 Then iRecCurrent = 0 If iRecCurrent < iRecEnd Then iRecNext = iRecCurrent + iPageSize Else iRecNext = iRecEnd End If If iRecCurrent > 0 Then iRecPrev = iRecCurrent - iPageSize Else iRecPrev = 0 End If ' Do this so when calling the las page w ' e only loop through ' the number of records we have if less ' than the iPageSize If (iRecNext - iRecEnd ) > 0 Then iRecMax = iRecEnd - iRecCurrent Else iRecMax = iPageSize End If ' Start at the beginning of the database ' RecSet.MoveFirst 'Move to the record we want to start at RecSet.Move(iRecCurrent) ' use this when creating links ' doesn't matter what this page is named ' strScriptName = Request.ServerVariables("SCRIPT_NAME") %> <% Sub NavBar() Dim iPage Dim iVue Dim sNumbers Dim sPrev Dim sNext Dim sFirst Dim sLast Dim sNavBar Dim iLastPage iLastPage = iRecEnd - iPageSize For i = 0 To (iNumPage - 1) iPage = i * iPageSize iVue = i + 1 sNumbers = sNumbers & NavLink(strScriptName,iPage,gend,iVue) Next If iRecCurrent <> 0 Then sFirst = NavLink(strScriptName,0,gend,"First") sPrev = NavLink(strScriptName,iRecPrev,gend,"Previous") End If If (iRecCurrent + iRecMax) < iRecEnd Then sNext = NavLink(strScriptName,iRecNext,gend,"Next") sLast = NavLink(strScriptName,iLastPage,gend,"Last") End If sNavBar = sNumbers & "
" & sFirst & sPrev & sNext & sLast Response.Write(sNavBar) End Sub %> <% ' Creates the link used by the navigatio ' n sub Function NavLink(scriptName,pageNum,gendr, sWord) Dim strLink strLink = strLink & "" strLink = strLink & sWord strLink = strLink & " " NavLink = strLink End Function %> 5K Race Results

<% =sGender %> 5K Race

Records: <% =iRecCurrent %> - <% = iRecCurrent + iRecMax %> of <% =iRecEnd %>

<% NavBar %>

<% ' Use these for debugging 'Response.Write ("iRecCurrent: " & iRecC ' urrent & "
") 'Response.Write("iRecEnd: " & iRecEnd & ' "
") 'Response.Write("iRecMax: " & iRecMax & ' "
") 'Response.Write("iRecNext: " & iRecNext ' & "
") 'Response.Write("iRecPrev: " & iRecPrev ' & "
") 'Response.Write(CInt(iRecEnd/iPageSize) ' & "
") %> <% For i = 0 To iRecMax If i Mod 2 Then Response.Write ("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") Response.Write("") ' Move to the next record RecSet.MoveNext Next ' Clean up after yourself RecSet.Close Set RecSet = Nothing %>
Name Age City State Time Pace
") Else Response.Write("
") End If Response.Write(RecSet("FirstName") & " ") Response.Write(RecSet("LastName")& "" & RecSet("age") & "" & RecSet("City") & "" & RecSet("State") & "" & RecSet("Time" )& "" & RecSet("Pace") & "

<% Call NavBar %>