fireburner69
08-30-2002, 01:44 PM
Hello these is the code that i use to make the news section work in my site!
I seperate the news pages to 7 but the problem is that I want to be displayed from the last news to the 1st!
With these code It seperated the pages correct per 7 but the other way around!
Can someone help me out!
<%
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
' Move to the last record
objRS.MoveLast
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
'Display the data
if not objRS.EOF then
nRecordCount = 0
Do While Not objRS.BOF and nRecordCount < nPageSize
'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
' Do While Not objRS.eof and nRecordCount < nPageSize
nRecordCount = nRecordCount + 1
objRS.MovePrevious
loop
Else
response.write("No Records")
End if
' 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)
' Close & clean up
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
%>
I seperate the news pages to 7 but the problem is that I want to be displayed from the last news to the 1st!
With these code It seperated the pages correct per 7 but the other way around!
Can someone help me out!
<%
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
' Move to the last record
objRS.MoveLast
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
'Display the data
if not objRS.EOF then
nRecordCount = 0
Do While Not objRS.BOF and nRecordCount < nPageSize
'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
' Do While Not objRS.eof and nRecordCount < nPageSize
nRecordCount = nRecordCount + 1
objRS.MovePrevious
loop
Else
response.write("No Records")
End if
' 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)
' Close & clean up
objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
%>