Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 13th, 2004, 09:17 AM
tonya tonya is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 172 tonya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 31 sec
Reputation Power: 6
help with paging

I have a list that works great. Grabs all the records I want and displays them in pages of 10 records at a atime.

Now I want to have a link from each record in the list to a details page. I can do that no problem I get it to grab the database ID.

Then on the detail page I want a scroll at the bottom so that people can stay on that one detail page & view the previous one or next or first & last.

I havetried all sorts of code but just cant get it right !!

can anyone help ??

either by helping me with my code or giving me a better way of doing it

Dim myConn 'Database Connection Variable
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open "tonya"
Dim mySQL, myRS, mySQL2, myRS2, RecordID, i
RecordID = Request.QueryString("recid")
recdbno = Request.querystring("recdbno")
mySQL = "SELECT * FROM Journal ORDER BY date"
Set myRS = Server.CreateObject("ADODB.Recordset")
myRS.CursorLocation=3 'clientside
myRS.CursorType=3 'staticrecordset
myRS.Open mySQL, myConn
myRS.AbsolutePosition = recdbno

'If Request.QueryString("recdbno") = 0 Then
mySQL2 = "SELECT * FROM Journal WHERE id = " & recdbno
'Else
'mySQL2 = "SELECT * FROM Journal ORDER BY date"
'End If
Set myRS2 = Server.CreateObject("ADODB.Recordset")
myRS2.Open mySQL2, myConn
'myRS2.AbsolutePosition = RecordID

'catch to make sure scroll always takes us to first record or last
if myRS.EOF =true then
next_id=myRS.RecordCount
myRS.MoveLast()
elseif myRS.BOF =true then
previous_id=1
myRS.MoveFirst
end if

if RecordID<>myRS.RecordCount then
next_id=RecordID + 1
else
next_id=myRS.RecordCount
end if

if RecordID<>1 then
previous_id=RecordID - 1
else
previous_id=1
end if

%>
</p>
<table width="100%" height="69" border = "0" align="center" cellpadding="2" cellspacing="2" bordercolor="#FFFFFF">
<% While Not myRS2.EOF%>
<tr>
<td width="500" bordercolor="#CC99FF" bgcolor="#FFCCFF">
<p><em><%= myRS2("Date")%><br> </em>
<strong><%= myRS2("Title")%><br>
</strong> <%= myRS2("Text")%><br>
<%'Dim yes, no
'yes=""
'no="picture"
response.write "<img src='../graphics/journal/" & myRS2("pic") & "' border='0'>"
'If trim(myRS2("pic"))<>"" Then
'Response.Write(no)
'Else Response.Write(yes)
'End If%></p>
</td>
</tr>
<%

myRS2.MoveNext
Wend
%>
</table>
<p>Move to:
<a href="journal_display_scroll.asp?recid=1">First</a>
<a href="journal_display_scroll.asp?recid=<%=previous_id%>">Previous</a>
<a href="journal_display_scroll.asp?recid=<%=next_id%>">Next</a>
<a href="journal_display_scroll.asp?recid=<%=myRS.RecordCount%>">Last</a></p>
You are on Record <%=RecordId%> Of <%=myRS.RecordCount%>
<%
myRS.close
Set myRS = Nothing
myRS2.close
Set myRS2 = Nothing
myConn.close
Set myConn = Nothing
%>

theres my code.

in my links how do i get it to look at the record id or the database id & find the previous or next record ???

help please

Reply With Quote
  #2  
Old April 13th, 2004, 06:03 PM
tonya tonya is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 172 tonya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 31 sec
Reputation Power: 6
Wink

if you want to see what I am trying to get working look here !

http://www.tonya.me.uk/Journal/display.asp

The site is a playground. This is something a customer wants for a gallery so thought I would get it working really well & understand what I am coding first by trialing it & decided to trial it on my journal pages. I know dreamweaver can do all this but want to code it. The original code I had seems overly long winded but i am loosing my track of thought & think i am trying to overcomplicate matters. I am almost there with the following : -

Dim iPageCurrent ' The page we're currently on
Dim iPageCount ' Number of pages of records
Dim iRecordCount ' Count of the records returned
Dim iPageSize ' Count of records per page
Dim I ' Standard looping variable
Dim Rowcount ' number of rows
Dim strsort ' sorting collected by srt
Dim strcol ' sorting which column collected with col
Dim strhref 'holds additional href data of search values & pagesize

Dim myConn 'Database Connection Variable
Set myConn = Server.CreateObject("ADODB.Connection")
myConn.Open "tonya"
Dim mySQL
Dim myRS
Dim RecordID
Dim recdbno


RecordID = Request.QueryString("recid")
recdbno = Request.querystring("recdbno")

iPageSize = Request.Querystring("pagesize")
If iPageSize = "" Then
iPageSize = 1
Else iPageSize = Request.Querystring("pagesize")
End If

'setting up page numbering for later on in code
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If

'If Request.QueryString("recdbno") = "" Then
mySQL = "SELECT * FROM Journal ORDER BY date"
'Else
'mySQL = "SELECT * FROM Journal WHERE id = '" & recdbno & "' "
'End If

Set myRS = Server.CreateObject("ADODB.Recordset")
myRS.CursorType= adOpenStatic '3 'staticrecordset

myRS.PageSize = iPageSize
myRS.CacheSize = iPageSize
myRS.Open mySQL, myConn
'myRS.AbsolutePosition = recdbno

iRecordCount = myRS.RecordCount
iPageCount = myRS.PageCount
RowCount=0

myRS.AbsolutePage = iPageCurrent

strhref = "&search1=" & Server.URLEncode(strSearch) & "&pagesize=" & iPagesize %>
</p>
<table width="100%" height="69" border = "0" align="center" cellpadding="2" cellspacing="2" bordercolor="#FFFFFF">
<% While Not myRS.EOF and RowCount < myRS.PageSize%>
<tr>
<td width="500" bordercolor="#CC99FF" bgcolor="#FFCCFF">
<p><em><%= myRS("Date")%><br> </em>
<strong><%= myRS("Title")%><br>
</strong> <%= myRS("Text")%><br>
<%Dim yes, no
yes=""
no="<img src='../graphics/journal/" & myRS("pic") & "' border='0'>"
If trim(myRS("pic"))<>"" Then
Response.Write(no)
Else Response.Write(yes)
End If%></p>
<p> So I can test this I want to try
& get the database ID out -</p>
<p>I<%Response.Write myRS("ID")%>
</p>
</td>
</tr>
<%
RowCount = RowCount + 1
myRS.MoveNext
Wend%>
</table>
<div align="center">
<%If iPageCurrent > 1 Then%>
<a href="<%= strURL %>?page=<%=iPageCurrent-1 %>&pagesize=<%=ipagesize%>&cat=<%=Cat3%>">
<img src="../graphics/buttons/previous.gif" alt="PREVIOUS" width="39" height="33" border="0" align="absmiddle"></a>
&nbsp;
<%End If
If iPageCurrent < iPageCount Then%>
&nbsp; <a href="<%= strURL %>?page=<%=iPageCurrent+1%>&pagesize=<%=ipagesize%>&cat=<%=Cat5%>">
<img src="../graphics/buttons/next.gif" alt="NEXT" width="39" height="33" border="0" align="absmiddle"></a>
<%End If%>
</div>
<p>Move to: this is my test to get it to go to first record
<a href="display.asp?recdbno=1">First</a>

<%
myRS.close
Set myRS = Nothing
myConn.close
Set myConn = Nothing
%>


as before comment & help appreciated or somewhere to get sample code from !

Reply With Quote
  #3  
Old April 14th, 2004, 07:28 AM
tonya tonya is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 172 tonya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 31 sec
Reputation Power: 6
Maybe i am expecting too much. Perhaps its easier to have a link to a view record then scroll at bottom that links to another page entirely ! Or perhaps i do need to go back to my original idea of having two recordsets - because one recordset only retrieves one record & so doesnt show my scroll buttons at all. maybe the scrollbuttons need a second recordset but how do i get that recordset to link to the correct record or the two to syncronize - does that make sense ?

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > help with paging


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 5 hosted by Hostway
Stay green...Green IT