fireburner69
Programmer
This is the code witch i use in order to make a news page
I wanted to show in each page only 7 news and when the number goes more than 7 to go to the next page!
I have managed to make new page and so on but still in the first page shows all the news!
I the second page shows from the 8 and so on!
Any ideas why this is happening?
check the code!
<%
Dim nPage, nItems
'Collects Page References
nPage = request("p"
'No Page reference taken then default to first page
if isnumeric(nPage) and nPage <> "" then
if nPage > 0 then
nPage = cint(nPage)
else
nPage = 1
end if
else
nPage = 1
end if
'How many items to display per page
nItems = 7
' Define variants
Dim numID, strTitle, strStory, strLink, strSubmittedBy, strDatestamp, adOpenStatic, adLockReadOnly, adCmdTable, numCounter
adOpenStatic = 1
adLockReadOnly = 1
adCmdTable = 2
' Define database file type and location
Dim objConn, objRS, nRecordCount, nPageCount, nPageSize, sPrev, sNext
Set objConn = Server.CreateObject("ADODB.Connection"
Set objRS = Server.CreateObject("ADODB.Recordset"
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\athcfs01.hosting.forth\virtual\speftp\db\news.mdb;" & _
"Persist Security Info=False"
' Open News table in database
objRS.Open "News", objConn, adOpenStatic, adLockReadOnly, adCmdTable
' Open News table in database
' objRS.Open sSQL, objConn, adOpenStatic, adLockReadOnly, adCmdTable
objRS.cachesize= 3
objRS.PageSize = nItems
nRecordCount = objRS.RecordCount
nPageCount = objRS.PageCount
nPageSize = objRS.PageSize
if Cint(nPage) <= Cint(nPageCount) then
nPage = nPage
else
nPage = nPageCount
end if
objRS.AbsolutePage = nPage
' Create the navi
if Cint(nPage) = Cint(1) or Cint(nPage) = 0 then
sPrev = "<< Prev"
Else
sPrev = "<a href=""table.asp?p=" & (nPage - 1) & """><< Prev</a>"
End if
if Cint(nPage) = Cint(nPageCount) then
sNext = "Next >>"
Else
sNext = "<a href=""table.asp?p=" & (nPage + 1) & """>Next >></a>"
End if
if not objRS.eof then
' Display the Navi
response.write(sPrev & " | <b>" & nPage & "</b> of " & nPageCount & " | " & sNext)
'Display the data
Do until objRS.eof
response.Write("<p>"
if objRS("Link" <> " " then
response.write("<img src='linkicon.gif'> "
End If
response.Write("<a href='showstory.asp?storyid=" & objRS("ID" & "'>"
response.Write(objRS("Title" & "</a>"
response.Write("<br><small>" & objRS("Datestamp" & "</small><br><br>"
response.Write("</font></p>"
objRS.MoveNext
Loop
Else
response.write("No Records"
End if
' Close & clean up
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
%>
thanx for your time!
I wanted to show in each page only 7 news and when the number goes more than 7 to go to the next page!
I have managed to make new page and so on but still in the first page shows all the news!
I the second page shows from the 8 and so on!
Any ideas why this is happening?
check the code!
<%
Dim nPage, nItems
'Collects Page References
nPage = request("p"
'No Page reference taken then default to first page
if isnumeric(nPage) and nPage <> "" then
if nPage > 0 then
nPage = cint(nPage)
else
nPage = 1
end if
else
nPage = 1
end if
'How many items to display per page
nItems = 7
' Define variants
Dim numID, strTitle, strStory, strLink, strSubmittedBy, strDatestamp, adOpenStatic, adLockReadOnly, adCmdTable, numCounter
adOpenStatic = 1
adLockReadOnly = 1
adCmdTable = 2
' Define database file type and location
Dim objConn, objRS, nRecordCount, nPageCount, nPageSize, sPrev, sNext
Set objConn = Server.CreateObject("ADODB.Connection"
Set objRS = Server.CreateObject("ADODB.Recordset"
objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=\\athcfs01.hosting.forth\virtual\speftp\db\news.mdb;" & _
"Persist Security Info=False"
' Open News table in database
objRS.Open "News", objConn, adOpenStatic, adLockReadOnly, adCmdTable
' Open News table in database
' objRS.Open sSQL, objConn, adOpenStatic, adLockReadOnly, adCmdTable
objRS.cachesize= 3
objRS.PageSize = nItems
nRecordCount = objRS.RecordCount
nPageCount = objRS.PageCount
nPageSize = objRS.PageSize
if Cint(nPage) <= Cint(nPageCount) then
nPage = nPage
else
nPage = nPageCount
end if
objRS.AbsolutePage = nPage
' Create the navi
if Cint(nPage) = Cint(1) or Cint(nPage) = 0 then
sPrev = "<< Prev"
Else
sPrev = "<a href=""table.asp?p=" & (nPage - 1) & """><< Prev</a>"
End if
if Cint(nPage) = Cint(nPageCount) then
sNext = "Next >>"
Else
sNext = "<a href=""table.asp?p=" & (nPage + 1) & """>Next >></a>"
End if
if not objRS.eof then
' Display the Navi
response.write(sPrev & " | <b>" & nPage & "</b> of " & nPageCount & " | " & sNext)
'Display the data
Do until objRS.eof
response.Write("<p>"
if objRS("Link" <> " " then
response.write("<img src='linkicon.gif'> "
End If
response.Write("<a href='showstory.asp?storyid=" & objRS("ID" & "'>"
response.Write(objRS("Title" & "</a>"
response.Write("<br><small>" & objRS("Datestamp" & "</small><br><br>"
response.Write("</font></p>"
objRS.MoveNext
Loop
Else
response.write("No Records"
End if
' Close & clean up
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
%>
thanx for your time!