ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 12th, 2003, 11:00 AM
amuller24 amuller24 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 19 amuller24 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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>

Reply With Quote
  #2  
Old June 12th, 2003, 07:07 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Paging Recordset - Working - Needs formatting


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT