/ Published in: ASP
Expand |
Embed | Plain Text
dim iContentPerPage : iContentPerPage = 4 dim iTotalRecords: iTotalRecords = request.querystring("total") dim iStart: iStart = request.querystring("start") dim sAlpha: sAlpha = request.querystring("a") dim iEnd,iTotalRecords 'get total records if ((len(iTotalRecords) = 0) or (not isnumeric(iTotalRecords))) then strsql = "select count(id) FROM [TABLE] " & sqlEx itemArray = selectDatabase(strsql) iTotalRecords = itemArray(0,0) end if 'set the starting position, either zero or from the query string if (len(iStart) = 0) then iStart = 1 else iStart = Cint(iStart) end if 'set the end position 'if the number of items per page plus the starting position is less than the total, 'then show the number of items added to the starting position 'otherwise we are at the end If (cint(iTotalRecords) >= (iContentPerPage + iStart)) Then iEnd = iContentPerPage + iStart-1 Else iEnd = iTotalRecords End If if (len(sAlpha) > 0) then _ sqlEx = "WHERE substring([FIELD],1,1) = '" & sAlpha & "' " strsql = "select member_id,uniqueid,screenname from " &_ "(SELECT ROW_NUMBER() OVER (order by screenname asc) AS Row, row_id FROM [TABLE] "&sqlEx&") AS LogWithRowNumbers " &_ "WHERE Row >= "&iStart&" AND Row <= "&iEnd itemArray = selectDatabase(strsql) 'display results if isArray(itemArray) then for introw = 0 to ubound(itemArray,2) id = itemArray(0,introw) next end if response.write "<br /><table border=""0"" width=""95%"" cellpadding=""2"" cellspacing=""0"" align=""center""><tr>" 'check whether to show the previous link or not if (iStart > iContentPerPage) then response.write "<td style=""width:33%;"" align=""left""><a href="""&scriptName&"?start="&(iStart-iContentPerPage)&"&total="&iTotalRecords&""" style=""text-decoration:none;""><< PREVIOUS PAGE</a></td>" else response.write "<td style=""width:33%;""> </td>" end if response.write "<td style=""width:33%;"" align=""center"">" & (iEnd) & " of " & (iTotalRecords) & "</td>" 'check whether to show the next link or not if (cint(iEnd) < cint(iTotalRecords)) then response.write "<td style=""width:33%;"" align=""right""><a href="""&scriptName&"?start="&(iEnd+1)&"&total="&iTotalRecords&""" style=""text-decoration:none;"">NEXT PAGE >></a></td>" else response.write "<td style=""width:33%;""> </td>" end if
You need to login to post a comment.
