Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paging with several tables.

Status
Not open for further replies.

lizzi

Technical User
Feb 12, 2004
45
0
0
SE
Hi
Wonder if someone could help me with this: I have this page: I would like to transform into paging. I´ve created this paging: Now to my problem. I would like to put in the comments in the paging side to, but I don´t now how this becuase the comments is in a own table. On the first page I solved it like this:
Code:
<%
' ## SELECT THE SELECTED POST
SQL = "SELECT * FROM [news] WHERE bolview = TRUE ORDER BY [dteCreated]DESC " 
set mySQL = Conn.Execute(SQL)

DO UNTIL mySQL.EOF
' ## NEWS
tmp = tmp & "<p><b>" & trimMyIcons(mySQL("strSubject")) &"</b>" & vbCRLF
tmp = tmp & mySQL("dteCreated") & "</p>" & vbCRLF
tmp = tmp & "<table width=""400"" border=""0"" cellspacing=""0"" cellpadding=""5"" class=""tdborder"">" & vbCRLF
tmp = tmp & "<tr>" & vbCRLF
tmp = tmp & "<td width=""400"" bgcolor=""#E6E6E6"" valign=""top"">" 
tmp = tmp & "<p>" & trimMyIcons(mySQL("strMessage")) & "</p></td></tr>" & vbCRLF
tmp = tmp & "</table>" & vbCRLF
tmp = tmp & "<table width=""380"" border=""0"" cellspacing=""0"" cellpadding=""0"">" & vbCRLF
tmp = tmp & "<tr>" & vbCRLF
tmp = tmp & "<td width=""380"" valign=""top"" align=""right"" class=""links"">" & mySQL("intCommentCounter")  
tmp = tmp & "<a href=""index.asp?open=" & mySQL("intId") & """ class=""links""> comments</a>" & vbCRLF  & "</td>"
tmp = tmp & "</tr></table>" & vbCRLF

' ## COMMENT
'## SELECT THE SELECTED POST
SQL2 = "SELECT * FROM [comments] WHERE [intNewsId] = " & mySQL("intId") & ";"
set mySQL2 = Conn.Execute(SQL2)

If Int(Request.QueryString("open")) = mySQL("intId") Then
	DO UNTIL mySQL2.EOF
		tmp = tmp & "<table width=""400"" border=""0"" cellspacing=""0"" cellpadding=""0"">" & vbCRLF
		tmp = tmp & "<tr>" & vbCRLF
		tmp = tmp & "<td width=""200"" valign=""top"">" & vbCRLF
		tmp = tmp & mySQL2("strName")
		If  mySQL2("stremail") <> "" then tmp = tmp & " <a href=""mailto:" & mySQL2("stremail") & """ class=""links"">email</a>" 
		If  mySQL2("strurl") <> "" then tmp = tmp & "   <a href="""& mySQL2("strurl") & """ target=""_blank"" class=""links"">url</a>" 
		tmp = tmp & "</td>" & vbCRLF
		tmp = tmp & "<td width=""200"" align=""right"" valign=""top"">" & vbCRLF
		tmp = tmp & mySQL2("dteCreated")
		tmp = tmp & "</td></tr>" & vbCRLF
		tmp = tmp & "<tr>" & vbCRLF
		tmp = tmp & "<td colspan=""2"">" & vbCRLF
		tmp = tmp & "<table width=""400"" border=""0"" cellspacing=""0"" cellpadding=""5"" align=""center"" class=""tdborder"">" & vbCRLF
		tmp = tmp & "<tr>" & vbCRLF
		tmp = tmp & "<td width=""400"" valign=""top"">" & trimMyIcons(mySQL2("strMessage"))
		tmp = tmp & "</td></tr></table></td></tr></table><br/>" & vbCRLF
	mySQL2.MoveNext
	LOOP
tmp = tmp & "<a href=""/engstrand/index.asp"" class=""links"">Back</a>"  
END IF

intNewsID = mySQL("intId")
mySQL.MOVENEXT

If Int(Request.QueryString("open")) = intNewsID Then
	tmp = tmp & "<table width=""400"" border=""0"" cellspacing=""0"" cellpadding=""0"">" & vbCRLF _
	& "<tr>" & vbCRLF _
	& "<td width=""400"">" & vbCRLF _
	& "<table width=""380"" border=""0"" cellspacing=""0"" cellpadding=""0"" align=""center"">" & vbCRLF _
	& "<tr>" & vbCRLF _
	& "<td width=""380"" valign=""top"" cellpadding=""5"">" &vbCRLF _ 
	& "<form name=""form1"" id=""form1"" method=""post"" action=""/engstrand/confirm.asp"">" & vbCRLF _
	& "<p><br/>Write a comment<br/><br/><br/>" _
	& "<input type=""text"" name=""name"" SIZE=""8"" value=""Name"" class=""form""><br/></input>" _
	& "<input type=""text"" name=""email"" SIZE=""8"" value=""@"" class=""form""><br/></input>" _
	& "<input type=""text"" name=""url"" SIZE=""8"" value=""[URL unfurl="true"]http://""[/URL] class=""form""><br/></input>" _
	& "<textarea cols=""15"" rows=""6"" name=""comments"" class=""form""></textarea>" _
	& "<input type=""hidden"" value=""" & intNewsID & """ name=""intNewsId""></input>"& vbCRLF _
	& "<input type=""submit"" value=""Save"" name=""submit1"" class=""form""></input></p></form></td></tr></table></td></tr></table>"
END IF

LOOP
response.write tmp
tmp = ""
%>

And the paging like this:
Code:
<%
Set objRs = Server.Createobject("Adodb.Recordset")
strSQL = "Select * from news Order by dteCreated DESC"
strConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath("\db\data\webdb.mdb")

'Set Conn = Server.CreateObject("ADODB.Connection")

intPageId = request.querystring( "pageid" )
if intPageId = "" then intPageId = 1

with objRs
  .cursorlocation = 3
  .open strSQL, strConString
  .pagesize = 10
  .absolutepage = intPageId
end with

intPages = cint( objRs.pagecount )
intCurrentPost = 0

do while not objRs.eof and intCurrentPost < objRs.pagesize
  strContents = strContents &_
    "<table><tr><td>" & objRs( "dteCreated" ) & "<p></td></tr></table>" &_
    "<table><tr><td>" & objRs( "strMessage" ) & "<p><p></td></tr></table>"

  intCurrentPost = intCurrentPost + 1
  objRs.movenext
loop

for i = 1 to objRs.pagecount
  strNavigation = strNavigation & " <a href='?pageid=" & i & "'>" & i & "</a>"
next

response.write "<table>" & strContents & "</table>"
response.write "<table><tr><td>" & strNavigation & "</td></tr></table>" 
%>

Sorry for the long thread. It would be nice if someone have a solution.
/Lizzi
 
How do you want it? Possible scenario:

initially:
10 posts, 0 comments.
---
10 items on page

clicking post 3, containing 3 comments:
3 posts
3 comments (from the 3rd post)
4 posts
---
10 items on page

something like that?

You might resolve that by creating an intermediate view that displays all posts PLUS the comments of the clicked post, with a max pagesize of 10.
 
Thanks for your answer, but could you give me some code example of that?

/Lizzi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top