主题:request("pages")的问题
<%
dim pages,currentcount
pages=cint(request.QueryString("pages"))
set rs=server.CreateObject("adodb.recordset")
if request.QueryString()<>"" and request.QueryString("book_id")<>"" then
rs.open"delete from books where book_id="&amp;amp;amp;request.QueryString("book_id"),conn
end if
rs.open"select * from btype",conn,3,2
[color=FF0000]response.Write pages ' pages会等于0[/color]
rs.pagesize=20
if pages=0 then
pages=1
else
rs.move(pages-1)*rs.pagesize
end if
if pages<rs.pagecount then
currentcount=rs.pagesize
else
currentcount=rs.Recordcount-(pages-1)*rs.pagesize
end if
%>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
<tr valign="bottom">
<td height="46" colspan="2" style="padding-left:8px"> </td>
</tr>
<tr>
<td height="30" colspan="2"><table width="765" height="23" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1 dotted #cccccc">
<tr>
<td width="52" style="padding-top:4px"></td>
<td width="162" style="padding-top:4px"><a href="default.asp" class="font5">管理首页</a><strong>-->>书库记录管理</strong></td>
<td width="313"><div align="center" style="padding-top:4px"> </div></td>
<td width="151" style="padding-top:4px">当前管理员:<b><u><%response.Write session("account")%></u></b></td>
<td width="85"></td>
</tr>
</table></td>
</tr>
<tr>
<td width="110" valign="top" style="padding-left:8px;border-right-width:1px;border-right-style:double;border-right-color:#cccccc"><!--#include file="menu.asp"--></td>
<td width="670" valign="top">
<table width="660" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30"><div align="center">目前共有<span class="style11"> <%=rs.recordcount%> </span>种类型的书, 分<span class="style11">
<% =rs.pagecount %>
</span>页显示, 当前为第<span class="style11">
<% =pages %>
</span>页 </div></td>
</tr>
<tr>
<td>
<table width="320" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1 solid #eeeeee ">
<tr bgcolor="#EEFAFD">
<td width="200" height="25" style="padding-left:5px">图书类型</td>
<td width="40" style="padding-left:5px">添加</td>
<td width="40" style="padding-left:5px">修改</td>
</tr>
<%
for i=1 to currentcount
%>
<tr>
<td width="404" height="20"style="padding-left:5px"><%=rs("types")%></td>
<td width="40" style="padding-left:5px"><a href="typeaction.asp?types=<% =rs("types")%> " class="font1">添加</a></td>
<td width="40" style="padding-left:5px"><a href="typeaction.asp?types=<% =rs("types")%> " class="font1">修改</a>
</td>
</tr>
<%
if not rs.eof then rs.movenext
next
%>
</table></td>
</tr>
<tr>
<td height="20"><div align="center">
<%
if pages>1 then
response.write"<a href='managebtype.asp?pages="&pages-1&"'>前一页</a>&nbsp;"
else
response.Write"前一页&nbsp;"
end if
for i=1 to rs.pagecount
if pages=i then
response.Write"第"&i&"页"
else
response.Write"<a href='managebtype.asp.asp?pages="&i&"'>第"&i&"页</a>"
end if
response.Write"&nbsp;"
next
if pages<rs.pagecount then
response.Write"<a href='managebtype.asp.asp?pages="&pages+1&"'>后一页</a>&nbsp;"
else
response.Write"后一页"
end if
%>
</div></td>
</tr>
</table>
</td>
</tr>
<%
else
response.Write"你没有登录!无权进入管理区!"
end if
%>
<tr>
<td height="30" colspan="2" style="line-height:150%"><table width="765" height="23" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1 dotted #cccccc">
<tr>
<td><!--#include file="../bottom.asp" --></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
上面的程序是分页程序的一部分.我做了个测试就是那显示红色的部分.在BTYPE表里面有6个记录,应该是pages=6才可以,但是程序老是运行成pages=0.很奇怪.
这段代码是图书管理的一部分...
在BTYPE表中只有一个字段那就是TYPES 类型为nvarchar 它有六条记录.就是图书的类型.有6个类型.
谢谢!
dim pages,currentcount
pages=cint(request.QueryString("pages"))
set rs=server.CreateObject("adodb.recordset")
if request.QueryString()<>"" and request.QueryString("book_id")<>"" then
rs.open"delete from books where book_id="&amp;amp;amp;request.QueryString("book_id"),conn
end if
rs.open"select * from btype",conn,3,2
[color=FF0000]response.Write pages ' pages会等于0[/color]
rs.pagesize=20
if pages=0 then
pages=1
else
rs.move(pages-1)*rs.pagesize
end if
if pages<rs.pagecount then
currentcount=rs.pagesize
else
currentcount=rs.Recordcount-(pages-1)*rs.pagesize
end if
%>
<table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
<tr valign="bottom">
<td height="46" colspan="2" style="padding-left:8px"> </td>
</tr>
<tr>
<td height="30" colspan="2"><table width="765" height="23" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1 dotted #cccccc">
<tr>
<td width="52" style="padding-top:4px"></td>
<td width="162" style="padding-top:4px"><a href="default.asp" class="font5">管理首页</a><strong>-->>书库记录管理</strong></td>
<td width="313"><div align="center" style="padding-top:4px"> </div></td>
<td width="151" style="padding-top:4px">当前管理员:<b><u><%response.Write session("account")%></u></b></td>
<td width="85"></td>
</tr>
</table></td>
</tr>
<tr>
<td width="110" valign="top" style="padding-left:8px;border-right-width:1px;border-right-style:double;border-right-color:#cccccc"><!--#include file="menu.asp"--></td>
<td width="670" valign="top">
<table width="660" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30"><div align="center">目前共有<span class="style11"> <%=rs.recordcount%> </span>种类型的书, 分<span class="style11">
<% =rs.pagecount %>
</span>页显示, 当前为第<span class="style11">
<% =pages %>
</span>页 </div></td>
</tr>
<tr>
<td>
<table width="320" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1 solid #eeeeee ">
<tr bgcolor="#EEFAFD">
<td width="200" height="25" style="padding-left:5px">图书类型</td>
<td width="40" style="padding-left:5px">添加</td>
<td width="40" style="padding-left:5px">修改</td>
</tr>
<%
for i=1 to currentcount
%>
<tr>
<td width="404" height="20"style="padding-left:5px"><%=rs("types")%></td>
<td width="40" style="padding-left:5px"><a href="typeaction.asp?types=<% =rs("types")%> " class="font1">添加</a></td>
<td width="40" style="padding-left:5px"><a href="typeaction.asp?types=<% =rs("types")%> " class="font1">修改</a>
</td>
</tr>
<%
if not rs.eof then rs.movenext
next
%>
</table></td>
</tr>
<tr>
<td height="20"><div align="center">
<%
if pages>1 then
response.write"<a href='managebtype.asp?pages="&pages-1&"'>前一页</a>&nbsp;"
else
response.Write"前一页&nbsp;"
end if
for i=1 to rs.pagecount
if pages=i then
response.Write"第"&i&"页"
else
response.Write"<a href='managebtype.asp.asp?pages="&i&"'>第"&i&"页</a>"
end if
response.Write"&nbsp;"
next
if pages<rs.pagecount then
response.Write"<a href='managebtype.asp.asp?pages="&pages+1&"'>后一页</a>&nbsp;"
else
response.Write"后一页"
end if
%>
</div></td>
</tr>
</table>
</td>
</tr>
<%
else
response.Write"你没有登录!无权进入管理区!"
end if
%>
<tr>
<td height="30" colspan="2" style="line-height:150%"><table width="765" height="23" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1 dotted #cccccc">
<tr>
<td><!--#include file="../bottom.asp" --></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
上面的程序是分页程序的一部分.我做了个测试就是那显示红色的部分.在BTYPE表里面有6个记录,应该是pages=6才可以,但是程序老是运行成pages=0.很奇怪.
这段代码是图书管理的一部分...
在BTYPE表中只有一个字段那就是TYPES 类型为nvarchar 它有六条记录.就是图书的类型.有6个类型.
谢谢!