<%
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
'decleration
dim fid,tp,tid
dim rs_fn
dim ParentID,name,email,subject,mes,mesdate,image1,image
Dim iPageSize 'How big our pages are
Dim iPageCount 'The number of pages we get back
Dim iPageCurrent 'The page we want to show
dim iRecordsShown,i,mesbody,em
'you can change the this value to how many records per page-----
iPageSize = 20
'---------------------------------------------------------------
if request("page")="" then
iPageCurrent = 1
else
iPageCurrent = cint(request.querystring("page"))
end if
response.write ""
function getForumName(id)
set rs_fn=server.createObject("adodb.recordset")
set conn=server.createobject("adodb.connection")
conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; "& "DBQ=" & Server.Mappath("../db/data.mdb") & ""
sql="select forumid,forumname,body from myforums where forumid="&id
rs_fn.open sql,conn
' response.write rs_fn("forumname") &"//" &rs_fn("body")
' response.end
response.write "
"& rs_fn("forumname") & " " & rs_fn("body") & "
"
rs_fn.close
set rs_fn=nothing
end function
'take forum id number from querystring
fid=request("fid")
'image1=""
call headers()
sql="select mesbody,id,thread_id,name,email,subject,mesdate,forumID,thread_parent from mestbl WHERE (forumid = " & fid & ") and thread_parent=0 order by id desc"
'connect to db
call connect()
Rs.Open sql, conn,adOpenStatic, adLockReadOnly, adCmdText
RS.PageSize = iPageSize
RS.CacheSize = iPageSize
iPageCount = RS.PageCount
iRecordsShown = 0
'if no messages in forum
response.write getForumName(fid)
If iPageCount = 0 Then
'Response.Write "
No messages in forum
"
else
RS.AbsolutePage = iPageCurrent
'grab all records
Do While iRecordsShown < iPageSize And Not RS.EOF
tid=rs("thread_id")
ParentID=rs("id")
name=rs("name")
email=rs("email")
subject=replace(rs("subject"),"''","'")
mesdate=rs("mesdate")
mesbody = rs("mesbody")
if mesbody="" then
em="EM"
else
em=""
end if
response.write "
"
'calling procedure to show childs
call displayMessages(1,ParentID)
rs.movenext
iRecordsShown = iRecordsShown+1
loop
end if
call close()
response.write "
"
if iPageCount>1 then
response.write "pages"
for i = ipagecount to ipagecount-10 step -1
if i>0 then
response.write " | " & i & ""
end if
next
response.write " Page " & iPageCount-iPageCurrent+1 & " From " & iPageCount & " "
end if
response.write "