fireburner69
Programmer
OkI have these code that i use in a news section! But I can not understand where is the problem.
I want to make it to show the news from the last to the old one. I have done that but it seperates the pages in the other way! So when i have 15 news page One has 1 new page TWO has 7news and page 3 has 7news(which are the most recent news I input)
These is 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
' 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
%>
Thanx for yout time and sorry for my English!
I want to make it to show the news from the last to the old one. I have done that but it seperates the pages in the other way! So when i have 15 news page One has 1 new page TWO has 7news and page 3 has 7news(which are the most recent news I input)
These is 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
' 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"
response.write("<img src='linkicon.gif'> "
End If
response.Write("<a href='showstory.asp?storyid=" & objRS("ID"
response.Write(objRS("Title"
response.Write("<br><small>" & objRS("Datestamp"
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
%>
Thanx for yout time and sorry for my English!