Jump to content

Result Page


cool349

Recommended Posts

hello a long time search i have found the way i want my result page but now is the problem it does'nt show all the thumbs right most of the does not all and the links to the thumbs are correct.can anyone help me. o and the link for the thums he gets out og a database.

<%Option Explicit'declare variablesDim Currpage, pageLen, lastNumber, PageRem, PageTenDim connection, recordset, sSQL, sConnString, next10, prev10, PDim RSPrevPage, RSNextPage, start 'Get the current page the user is on, if it's the first time they'visit and the variable 'PageNo' is empty, then 'CurrPage' gets set to 1'Else the current page variable 'CurrPage' is set to the page number requestedIf IsEmpty(Request.Querystring("PageNo")) thenCurrPage = 1ElseCurrPage = Cint(Request.Querystring("PageNo"))End If 'the two functions below return the next 10 and prev 10 page numberFunction getNext10(num)pageLen = len(num)If pageLen = 1 Thennext10 = 10Else If pageLen>1 ThenpageRem = 10pageTen = right(num, 1)next10 = num + pageRem - pageTenEnd IfEnd IfgetNext10 = next10End FunctionFunction getPrev10(num)pageLen = len(num)If pageLen = 1 thenprev10 = 1Else If pageLen>1 thenlastNumber = right(num, 1)prev10 = num - lastNumber - 10End IfEnd IfIf prev10 = 0 thenprev10 = 1End IfgetPrev10 = prev10End Function'create an instance of the ADO connection and recordset objectSet Connection = Server.CreateObject("ADODB.Connection")Set Recordset = Server.CreateObject("ADODB.Recordset")'define the connection stringsConnString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _ "DBQ=" & Server.MapPath("db.mdb") & ";"'define our SQL variablesSQL="SELECT * FROM tbl_content WHERE plantnaam LIKE 'A%' ORDER BY [plantnaam] ASC" 'open an active connectionConnection.Open sConnString'Next set the location of the recordset to the client sideRecordset.CursorLocation = 3'Execute the SQL and return our recordsetRecordset.open sSQL, sConnString' pagesize is used to set the number of records that will be' displayed on each page. For our purposes 10 records is what we want.Recordset.PageSize = 14%><html><head><title>Recordset Paging Script</title></head><body><%'get the next 10 and prev 10 page numbernext10 = getNext10(CurrPage)prev10 = getPrev10(CurrPage)'the next 2 lines setup the page number for the "previous" and "next" linksRSPrevPage = CurrPage -1RSNextPage = CurrPage + 1'find out the number of pages returned in the recordset'if the Next10 page number is greater than the recordset page count'then set Next10 to the recordset pagecountIf Next10 > Recordset.PageCount ThenNext10 = Recordset.PageCountEnd If'the variable start determines where to start the page number navigation' i.e. 1, 10, 20, 30 and so on. If prev10 = 1 AND next10 - 1 < 10 Thenstart = 1Elsestart = Next10 - 14If right(start, 1) > 0 Thenstart = replace(start, right(start, 1), "0")start = start + 14End IfEnd If'This checks to make sure that there is more than one page of resultsIf Recordset.PageCount > 1 Then'Work out whether to show the Previous 10 '<<' If currpage > 1 Thenresponse.write("<a href=""paging.asp?PageNo=" & Prev10 & """><<</a> ")End If'Work out whether to show the Previous link '<' If NOT RSPrevPage = 0 thenresponse.write("<a href=""paging.asp?PageNo=" & RSPrevPage & """><</a> ")End If'Loop through the page number navigation using P as our loopcounter variable For P = start to Next10If NOT P = CurrPage thenresponse.write("<a href=""paging.asp?PageNo=" & P & """>" & P & "</a> ")Else'Don't hyperlink the current page number response.write(" <b>" & P & " </b>")End IfNext'this does the same as the "previous" link, but for the "next" linkIf NOT RSNextPage > Recordset.PageCount Thenresponse.write("<a href=""paging.asp?PageNo=" & RSNextPage & """>></a> ")End If'Work out whether to show the Next 10 '>>' If NOT Next10 = Recordset.PageCount Thenresponse.write(" <a href=""paging.asp?PageNo=" & Next10 & """>>></a><br><BR>")End IfEnd If'If there are no recordsIf Recordset.EOF ThenResponse.write "No records to display"Else'this moves the record pointer to the first record of the current pageRecordset.AbsolutePage = CurrPage'the below loop will loop until all the records of the current page have been'displayed or it has reached the end of the recordsetDo Until Recordset.AbsolutePage <> CurrPage OR Recordset.Eof'for our purposes our database has just 3 fields:'an 'ID' (autonumber field), 'SiteName' (textfield) and 'URL' (memofield)'you can change these according to your database and table fieldsresponse.write "<a href=" & Recordset ("link") & ">" & Recordset ("plantnaam") & "</a><br><br>"response.write "<hr>"Recordset.MoveNextLoopEnd If 'the next 2 lines setup the page number for the "previous" and "next" linksRSPrevPage = CurrPage -1RSNextPage = CurrPage + 1'find out the number of pages returned in the recordset'if the Next10 page number is greater than the recordset page count'then set Next10 to the recordset pagecountIf Next10 > Recordset.PageCount ThenNext10 = Recordset.PageCountEnd If'the variable start determines where to start the page number navigation' i.e. 1, 10, 20, 30 and so on. If prev10 = 1 AND next10 - 1 < 10 Thenstart = 1Elsestart = Next10 - 10If right(start, 1) > 0 Thenstart = replace(start, right(start, 1), "0")start = start + 10End IfEnd If'This checks to make sure that there is more than one page of resultsIf Recordset.PageCount > 1 Then'Work out whether to show the Previous 10 '<<' If currpage > 1 Thenresponse.write("<a href=""paging.asp?PageNo=" & Prev10 & """><<</a> ")End If'Work out whether to show the Previous link '<' If NOT RSPrevPage = 0 thenresponse.write("<a href=""paging.asp?PageNo=" & RSPrevPage & """><</a> ")End If'Loop through the page number navigation using P as our loopcounter variable For P = start to Next10If NOT P = CurrPage thenresponse.write("<a href=""paging.asp?PageNo=" & P & """>" & P & "</a> ")Else'Don't hyperlink the current page number response.write(" <b>" & P & " </b>")End IfNext'this does the same as the "previous" link, but for the "next" linkIf NOT RSNextPage > Recordset.PageCount Thenresponse.write("<a href=""paging.asp?PageNo=" & RSNextPage & """>></a> ")End If'Work out whether to show the Next 10 '>>' If NOT Next10 = Recordset.PageCount Thenresponse.write(" <a href=""paging.asp?PageNo=" & Next10 & """>>></a>")End IfEnd If' Close the recordset and connection objectRecordset.Close Set Recordset = NothingConnection.CloseSet Recordset =Nothing %></body></html>
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...