我郁闷了一天了,高手帮我指点一二。
<!--#include file="../Inc/CONN.ASP" -->
<!--#include file="../Inc/Function.Asp" -->
<%
'验证IP
call lockIP()
call isadmin()
if request("action")="update" then
types=request("pro_types")
set rs=server.createobject("adodb.recordset")
if types="" then
types="总排行"
else
sql="select * from [bigclass] where bigclassid="&types
rs.open sql,connstr,1,1
if not rs.eof then
types=trim(rs("bigclassname"))
end if
rs.close
end if
x=request.form("acount")
for i=1 to x
if trim(request.form("a"&i))="" then
sql="select * from [Top_pro] where bigclass='"&types&"' and order="&i
rs.open sql,connstr,1,1
if rs.eof then
d=0
else
d=1
end if
rs.close
if d=1 then
sql="delete [top_pro] where bigclass='"&types&"' and order="&i
rs.open sql,connstr,3,3
end if
rs.close
else
sql="select * from [product] where proid='"&request.form("a"&i)&"'"
rs.open sql,connstr,3,3
if not rs.eof then
proname=replace(trim(rs("proname")),vbcrlf,"")
html=replace(trim(rs("html")),vbcrlf,"")
end if
rs.close
sql="select * from [top_pro] where bigclass='"&types&"' and order="&i
rs.open sql,connstr,3,3
if rs.eof then
s=0
else
s=1
end if
rs.close
if s=0 then
sql="insert into [top_pro] (proname,proid,bigclass,orders,pro_html) values ('"&proname&"','"&request.Form("a"&i)&"','"&types&"',"&i&",'"&html&"')"
end if
if s=1 then
sql="update [top_pro] set proname='"&proname&"',proid='"&request.form("a"&i)&"',bigclass='"&types&"',order="&i&",pro_html='"&html&"'"
end if
set rs=conn.execute(sql)
rs.close
end if
next
set rs=nothing
conn.close
set rs=nothing
response.write"<script language='javascript'>alert('更新成功。');window.location='"&request.form("url")&"';</script>"
response.End()
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
<link href="../Style/admin.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function ch()
{
window.location='?types='+forma.types.value;
}
</script>
</head>
<body style="background-color:#FFFFFF">
<br />
<br />
<br />
<form action="?action=update" method="post" name="forma">
<div>
<select name="types" id="types" style="font-size:12px" onchange="ch();">
<option selected="selected">总 排 行</option>
<%
types=request("types")
set rs=conn.execute("select * from [bigclass]")
if not rs.eof then
do while not rs.eof
%>
<option value="<%=trim(rs("bigclassname"))%>" <%if request("types")=trim(replace(rs("bigclassname"),vbcrlf,"")) then response.write"selected='selected'" end if%>><%=trim(rs("bigclassname"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
</div><input name="url" type="hidden" value="<%=weburl()%>" />
<br />
<%
if types="总排行" or types="" then
sql="select top 16 * from [Top_Pro] where bigclass='总排行'"
x=16
redim preserve proids(16)
else
sql="select top 8 * from [Top_Pro] where bigclass='"&URLDecode(types)&"'"
x=8
redim preserve proids(8)
end if
redim preserve proids(8)
set rs=server.CreateObject("adodb.recordset")
rs.open sql,connstr,1,1
'response.write sql
if not rs.eof then
for i=1 to x
proids(i)=trim(rs("proid"))
rs.movenext
next
end if
rs.close
set rs=nothing
conn.close
set conn=nothing
for i=1 to x
%>
<div style="width:800px" align="center">
<div style="float:left;width:300px;height:30px;line-height:30px" align="right"><%=i%> </div>
<div style="float:left;width:400px;height:30px;line-height:30px" align="left"><input name="<%="a"&i%>" type="text" id="<%="a"&i%>" style="width:200px;height:18px" value="<%=proids(i)%>"/></div>
</div>
<%
next
%><input name="pro_types" type="hidden" value="<%=request("types")%>" /><input name="acount" type="hidden" value="<%=x%>" />
<div style="width:800px" align="center"><input name="提交" type="submit" value="更新该项" /></div>
</form>
</body>
</html>
上述代码是我在处理一个商品排行榜的,总是运行不正常。请高手帮助我修改一二。分不够可以再加