李胜素主演过霸王别姬:ASP高手进,复制的就别来了~

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 17:29:35
分页:
<!--#include file="conn.asp"-->
<%
Response.Write("<head><meta http-equiv='Content-Type' content='text/html; charset=gb2312' />")
Response.Write("<title>管理图片</title>")
Response.Write("<style type='text/css'>")
Response.Write("<!--form {")
Response.Write("margin: 0px;padding: 0px;border-top-width: 0px;border-right-width: 0px;border-bottom-width: 0px;border-left-width: 0px;")
Response.Write("}--></style></head>")
Response.Write("<body>")
Response.Write("<table width='100%' border='0' bgcolor='#CCCCCC'><tr>")
Response.Write("<th width='10%' height='25'>id</th><th width='21%' height='25'>IAMGE</th><th width='25%' height='25'>IMAGE1</th><th width='23%' height='25'>TIME</th><th width='21%' height='25'>MASTER</th></tr>")
set rs=server.CreateObject("adodb.recordset")
sql="select * from [user] order by id desc"
rs.open sql,conn,1,1
if (rs.eof and rs.bof) then
Response.Write("<div align='center'><font color='red'>当前没有记录</font></a>")
else
maxpage=20
rs.pagesize=maxpage
totalpage=rs.pagecount
totalcount=rs.recordcount
page=Trim(Request.querystring("page"))
if page="" then page=1
if page<>"" then page=clng(page)
if page>totalpage then page=totalpage
if page<1 then page=1
rs.absolutepage=page
i=0
while not rs.eof and i<maxpage
Response.Write("<tr><td bgcolor='#FFFFFF'>"&rs("id")&"</td><td bgcolor='#FFFFFF'>"&rs("lxname")&"</td><td bgcolor='#FFFFFF'>"&rs("lxtel")&"</td><td bgcolor='#FFFFFF'>"&rs("time")&"</td>")
Response.Write("<td bgcolor='#FFFFFF'><a href='list.asp?id="&rs("id")&"'>查看详情</a></div></td></tr>")
i=i+1
rs.movenext
wend
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
Response.Write("</table><p> </p>")
%>
<%
if page>4 then:sp=page-4:else:sp=1:end if
for i=sp to sp+8
if i>totalpage then exit for
if i=page then
Response.Write i&" "
else
Response.Write "<a href='?page="&i&"'>"&i&"</a> "
end if
next
'显示记结束,分页结束!!页面结束!!!!!
%>
list.asp
<!--#include file="conn.asp"-->
<%dim id
id=request.form("id")
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from [user] where id="&id,conn,1,1
rs.Open sql,conn,1,1
do while not rs.eof
%>
<%=rs("lxname")%>
<%
rs.movenext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
为什么在点示 查看详情 的时候老是死循环,CPU占用100% ,是list.asp或取不到id号码?具体应该怎么做?

id=request.form("id") 在这里是不对的

可以用id=request("id")

因为request.form("id") 的意思是从表单提交来的ID值,你没有用表单,当然取不到。

while not rs.eof and i<maxpage

改为 while not rs.eof and int(i)<int(maxpage) 我以前也碰到这样的问题!

if page>4 then:sp=page-4:else:sp=1:end if
这样写多恶心呢!改好好排错,

for i=sp to sp+8
if i>totalpage then exit for
if i=page then
Response.Write i&" "
else
Response.Write "<a href='?page="&i&"'>"&i&"</a> "
end if
next
如果死循环是在这里的话我想应该也是 if i>totalpage then exit for这里出错同样加上 int(i)>int(totalpage)

注意:
while not rs.eof and i<maxpage
改为:
while not rs.eof Or i<maxpage
试一下

或者不要跟在while not rs.eof 后面
在下面嵌套个IF