|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Paging Recordset - Working - Needs formatting
Hi,
I have taken a script from the 4guysfromrolla website, to page through a recordset in ASP. I have been able to make the script to work, but i'm having problems trying to display the data in the format I wish. Currently it displays the data in tables Vertically (spelling) like X X X x X But i want to display the data in groups of either 3 or 4 like X X X X X X X X Can anybody help me?! I have attached the code below that i am using. Thanks in advanced Allan ************************************************ <%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit %> <!--#include file="ADOVBS.inc"--> <% 'Set how many records per page we want Const NumPerPage = 6 'Retrieve what page we're currently on Dim CurPage If Request.QueryString("CurPage") = "" then CurPage = 1 'We're on the first page Else CurPage = Request.QueryString("CurPage") End If Dim conn Dim CONN_STRING Dim CONN_USER Dim CONN_PASS Dim PAGE_NAME CONN_STRING = "Data Source=" & Server.MapPath("wallpaper.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;" CONN_USER = "" CONN_PASS = "" Set conn = Server.CreateObject("ADODB.Connection") conn.Open CONN_STRING, CONN_USER, CONN_PASS 'Explicitly Create a recordset object Dim rs Set rs = Server.CreateObject("ADODB.Recordset") 'Set the cursor location property rs.CursorLocation = adUseClient 'Set the cache size = to the # of records/page rs.CacheSize = NumPerPage 'Open our recordset Dim strSQL strSQL = "SELECT * FROM wallpapers WHERE IMGCat='FEMALE';" rs.Open strSQL, Conn rs.MoveFirst rs.PageSize = NumPerPage 'Get the max number of pages Dim TotalPages TotalPages = rs.PageCount 'Set the absolute page rs.AbsolutePage = CurPage 'Counting variable for our recordset Dim count %> <HTML> <TITLE>WALLPAPER</TITLE> <link href="styles.css" rel="stylesheet" type="text/css"> <BODY> <% 'Set Count equal to zero Count = 0 Do While Not rs.EOF And Count < rs.PageSize %> <table width="650" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><div align="center"><a href="portfolio2.asp?IDnumber=<%=RS("IMGID")%>"><img src="wallpapers/<%=RS("IMGsrc")%>.jpg" width="132" height="176" alt="ID Number:<%=RS("IMGID")%>" border="0"></a></div></td> </tr> <tr class="txt"> <td align="center">Image Size: <%=RS("IMGSize")%></td> </tr> <tr class="txt"> <td align="center">File Size: <%=RS("IMGFileSize")%></td> </tr> <tr class="txt"> <td align="center">ID Number: <%=RS("IMGID")%></td> </tr> <tr class="txt"> <td align="center">Rating: <img src="rating4.gif" width="102" height="13"></td> </tr> </table> <% Count = Count + 1 rs.MoveNext Loop 'Print out the current page # / total pages Response.Write("Page " & CurPage & " of " & TotalPages & "<P>") 'Display Next / Prev buttons if CurPage > 1 then 'We are not at the beginning, show the prev button Response.Write("<INPUT TYPE=BUTTON VALUE=PREV ONCLICK=""document.location.href='Untitled-2.asp?curpage=" & curpage - 1 & "';"">") End If if CInt(CurPage) <> CInt(TotalPages) then 'We are not at the end, show a next button Response.Write("<INPUT TYPE=BUTTON VALUE=NEXT ONCLICK=""document.location.href='Untitled-2.asp?curpage=" & curpage + 1 & "';"">") End If %> </BODY> </HTML> |
|
#2
|
||||
|
||||
|
Basically you need 2 loops.
The outter one handles the rows, and the inner one handles the columns. Code:
FOR each row
response.write("<tr>")
FOR idx = 1 to numColumns
response.write("<td>" & value & "</td>")
NEXT
response.write("</tr>")
NEXT
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > ASP Development > Paging Recordset - Working - Needs formatting |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|