|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
displaying the first 20
I have an access database and users can search through it.
Is it possible to display the first 20 results on one page and then display the next 20 on another page and so on and so on.. |
|
#2
|
|||
|
|||
|
Of course...anything is possible
What you ask for is called paging perhaps search google.com for code examples, trust me you'll find plenty...here type this inside google.com's textbox "Paging using ASP" Hope this helps! Sincerely Vlince |
|
#3
|
|||
|
|||
|
hi gintom,
of course u can. here is a sample, assuming u know the basic codes already. i used this in my asp pages. hope it works out for you. Michael <% ' this page is named SamePage.asp ' yr connection here Set con = Server.CreateObject("ADODB.Connection") ... DIM pgid, rowCount, i pgid = trim(request.queryString("pgid")) if pgid = "" then pgid = 1 end if set rs = Server.CreateObject("ADODB.Recordset") rs.CursorType = adOpenStatic rs.PageSize = 20 'chg this value, this will display 20 results per page rs.open "SELECT * from TableName", con if not rs.eof then if rs.recordcount <= rs.pagesize then rs.AbsolutePage = 1 else rs.AbsolutePage = cint(pgid) end if rowCount = 0 end if %> <html> <body> <table> <% while not rs.eof and rowCount < rs.PageSize i = 1 abc = trim(rs("Name")) %> <tr> <td><%=abc%></td> </tr> <% rowCount = rowCount + 1 rs.movenext wend %> <tr> <td>Page <%for i = 1 to rs.PageCount%> <a href="SamePage.asp?pgid=<%=i%>"><%if Cint(pgid)=i then%><font size="2" color="#ff0000"><b><%=i%></b></font><%else%><%=i%><%end if%></a> <%if i<>rs.PageCount then%>::<%end if%><%next%></span></td> </tr> </table> </body> </html> <!-- remember to close conenctions here --> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > displaying the first 20 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|