Hi Guys.
Still relatively new to programming, Ive nearly finished my first asp page.
It just displays some records from an access database, and Im trying to write code to page the information.
ideally I would like <prev 1 2 3 * * * * next>
but at the moment the code just does PREV & NEXT, and even that is causing a problem. It displays the same 5 records as I cycle through the next link??
<!--Page encoded by David James Tosh, 2002/2003-->
<!--ASP page that process the information-->
<%@ Language = "VBScript"%>
<%
'Declare all local variables
'connections
dim conn
dim rs
dim strconn
dim sql
'page numbering
dim currentPage
dim NumRows
'set a local variable to my DSN-less connection String
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("recordsnorthwest.mdb"
'Create the Connection object
set conn = server.createobject("adodb.connection"
conn.open strconn
sql = "SELECT * FROM stock"
'Create the recordset object
set rs = server.createobject("adodb.recordset"
'This statement opens the table so we can add a record notice the addnew
'The 2, 2 is how the table is opened
rs.open sql, conn, 3
rs.PageSize=5
%>
<html>
<head>
<title>View Database Contents</title>
</head>
<body>
<table >
<tr>
<th>Picture </th>
<th>Artist </th>
<th>Title </th>
<th>Label </th>
<th>Comment </th>
<th>Category </th>
<th>Year Made </th>
<th>Price </th>
<th>Mp3 </th>
<th>Cost </th>
<th>DateLogged </th>
<th>InStock </th>
<th>Owner </th>
</tr>
<%
NumRows=0
Do Until RS.EOF OR NumRows>=RS.PageSize
%>
<tr>
<td><img src= <td> <%=RS("Artist"%> </td>
<td> <%=RS("Title"%> </td>
<td> <%=RS("Label"%> </td>
<td> <%=RS("Comment"%> </td>
<td> <%=RS("Category"%> </td>
<td> <%=RS("YearMade"%> </td>
<td> <%=RS("Price"%> </td>
<td><a href=" <td> <%=RS("Cost"%> </td>
<td> <%=RS("DateLogged"%> </td>
<td> <%=RS("InStock"%> </td>
<td> <%=RS("Owner"%> </td>
</tr>
<%
RS.MoveNext
NumRows=NumRows+1
Loop
%>
</table>
<br>
<a href="default.asp">Return</a> to main menu
<br>
<br>
<!--number pages next and previous-->
<div align=center>
<%
If currentPage>1 Then
%>
<a href="query.asp?page=<%=currentPage-1%>">Prev</a>
<%
End If
%>
<%
If currentPage<RS.PageCount Then
%>
<a href="query.asp?page=<%=currentPage+1%>">Next</a>
<%
End If
%>
</div>
</body>
</html>
If someone could help suggest how I can get this working, or even include numbers in between the prev and next links (like google uses) that would be awesome.
Ive been pulling my hair out.
MANY THANKS
Dave
Still relatively new to programming, Ive nearly finished my first asp page.
It just displays some records from an access database, and Im trying to write code to page the information.
ideally I would like <prev 1 2 3 * * * * next>
but at the moment the code just does PREV & NEXT, and even that is causing a problem. It displays the same 5 records as I cycle through the next link??
<!--Page encoded by David James Tosh, 2002/2003-->
<!--ASP page that process the information-->
<%@ Language = "VBScript"%>
<%
'Declare all local variables
'connections
dim conn
dim rs
dim strconn
dim sql
'page numbering
dim currentPage
dim NumRows
'set a local variable to my DSN-less connection String
strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("recordsnorthwest.mdb"
'Create the Connection object
set conn = server.createobject("adodb.connection"
conn.open strconn
sql = "SELECT * FROM stock"
'Create the recordset object
set rs = server.createobject("adodb.recordset"
'This statement opens the table so we can add a record notice the addnew
'The 2, 2 is how the table is opened
rs.open sql, conn, 3
rs.PageSize=5
%>
<html>
<head>
<title>View Database Contents</title>
</head>
<body>
<table >
<tr>
<th>Picture </th>
<th>Artist </th>
<th>Title </th>
<th>Label </th>
<th>Comment </th>
<th>Category </th>
<th>Year Made </th>
<th>Price </th>
<th>Mp3 </th>
<th>Cost </th>
<th>DateLogged </th>
<th>InStock </th>
<th>Owner </th>
</tr>
<%
NumRows=0
Do Until RS.EOF OR NumRows>=RS.PageSize
%>
<tr>
<td><img src= <td> <%=RS("Artist"%> </td>
<td> <%=RS("Title"%> </td>
<td> <%=RS("Label"%> </td>
<td> <%=RS("Comment"%> </td>
<td> <%=RS("Category"%> </td>
<td> <%=RS("YearMade"%> </td>
<td> <%=RS("Price"%> </td>
<td><a href=" <td> <%=RS("Cost"%> </td>
<td> <%=RS("DateLogged"%> </td>
<td> <%=RS("InStock"%> </td>
<td> <%=RS("Owner"%> </td>
</tr>
<%
RS.MoveNext
NumRows=NumRows+1
Loop
%>
</table>
<br>
<a href="default.asp">Return</a> to main menu
<br>
<br>
<!--number pages next and previous-->
<div align=center>
<%
If currentPage>1 Then
%>
<a href="query.asp?page=<%=currentPage-1%>">Prev</a>
<%
End If
%>
<%
If currentPage<RS.PageCount Then
%>
<a href="query.asp?page=<%=currentPage+1%>">Next</a>
<%
End If
%>
</div>
</body>
</html>
If someone could help suggest how I can get this working, or even include numbers in between the prev and next links (like google uses) that would be awesome.
Ive been pulling my hair out.
MANY THANKS
Dave