Hi all.
I'm developing a small news system, and it's all done apart from the options to go back and forward with records, just like on top of this forums (Prev 1 2 3 4 5 Next) sort of thing.
I'm using ASP, developing it with Access for now, but will use MySQL when done.
Here's the bit I have done:
<%
newsPERpage = 5
Set Conn = Server.CreateObject("ADODB.Connection"
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("news.mdb"
'Count records
SQL = "SELECT COUNT(fld_newsID) AS recTOTAL FROM tbl_NEWS"
Set RS = Conn.Execute(SQL)
totalREC = RS("recTOTAL"
'Obtain list
SQL = "SELECT * FROM tbl_NEWS ORDER BY fld_newsID DESC"
Set RS = Conn.Execute(SQL)
%>
<TABLE ALIGN="center" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD>Posts per page: <%= newsPERpage %> - Total posts: <%= totalREC %> - Need to generate <%= totalREC / newsPERpage %> pages.</TD>
</TR>
</TABLE>
<BR>
<TABLE ALIGN="center" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD>Page: |
<%
For nPAGE = 1 to totalREC / newsPERpage
procPAGE = nPAGE
If Len(procPAGE) = 1 Then
procPAGE = "0" & procPAGE
End If
%>
<A HREF="news_list.asp&goPAGE=<%= nPAGE %>"><%= procPAGE %></A> |
<%
Next
%>
</TD>
</TR>
</TABLE>
<BR>
<%
Do While Not RS.Eof
'News records go here
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>
I think my approach so far is correct, but can't think of a way to make it work from here.
All help is appreciatted.
Thank you.
If you haven't heard of it, then you most likely don't need it.
---------------------------------------------------------------------
---------------------------------------------------------------------
I'm developing a small news system, and it's all done apart from the options to go back and forward with records, just like on top of this forums (Prev 1 2 3 4 5 Next) sort of thing.
I'm using ASP, developing it with Access for now, but will use MySQL when done.
Here's the bit I have done:
<%
newsPERpage = 5
Set Conn = Server.CreateObject("ADODB.Connection"
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("news.mdb"
'Count records
SQL = "SELECT COUNT(fld_newsID) AS recTOTAL FROM tbl_NEWS"
Set RS = Conn.Execute(SQL)
totalREC = RS("recTOTAL"
'Obtain list
SQL = "SELECT * FROM tbl_NEWS ORDER BY fld_newsID DESC"
Set RS = Conn.Execute(SQL)
%>
<TABLE ALIGN="center" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD>Posts per page: <%= newsPERpage %> - Total posts: <%= totalREC %> - Need to generate <%= totalREC / newsPERpage %> pages.</TD>
</TR>
</TABLE>
<BR>
<TABLE ALIGN="center" BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR>
<TD>Page: |
<%
For nPAGE = 1 to totalREC / newsPERpage
procPAGE = nPAGE
If Len(procPAGE) = 1 Then
procPAGE = "0" & procPAGE
End If
%>
<A HREF="news_list.asp&goPAGE=<%= nPAGE %>"><%= procPAGE %></A> |
<%
Next
%>
</TD>
</TR>
</TABLE>
<BR>
<%
Do While Not RS.Eof
'News records go here
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
%>
I think my approach so far is correct, but can't think of a way to make it work from here.
All help is appreciatted.
Thank you.
If you haven't heard of it, then you most likely don't need it.
---------------------------------------------------------------------
---------------------------------------------------------------------