我郁闷了一天了,高手帮我指点一二。

robake 2007-08-26 04:02:13
<!--#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>



上述代码是我在处理一个商品排行榜的,总是运行不正常。请高手帮助我修改一二。分不够可以再加
...全文
176 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
robake 2007-08-29
  • 打赏
  • 举报
回复
郁闷,还是我自己解决了。唉
robake 2007-08-28
  • 打赏
  • 举报
回复
回楼上的,数组定义部分没有问题,我这里的问题是出在写入数据库的时候,读的时候不存在错误。
www_7di_net 2007-08-27
  • 打赏
  • 举报
回复
不是不帮,而是你的问题恐怕只有你自己能明白
等你学会提问之后再来吧
ice241018 2007-08-27
  • 打赏
  • 举报
回复
你把问题描述清楚啊
bcexe 2007-08-27
  • 打赏
  • 举报
回复
编程动力 www.bcexe.com 专业的编程开发类网站,网络编程,软件开发,网页设计,平面设计,一切尽在这里!
bzsdonet 2007-08-27
  • 打赏
  • 举报
回复
连哪里不正常 都属不明白 让别人怎么帮!!!!!!
toury 2007-08-27
  • 打赏
  • 举报
回复
数组定义部分有问题没?检查一下 preserve....
robake 2007-08-27
  • 打赏
  • 举报
回复
晕。。。

上述代码运行时不报错。。却不是我想要的运行结果。

我的意思是这样的:

商城里有很多商品,依据商品编号来编制一个商品排行榜,包括所有商品的和每个分类的排行。

上述代码就是朝这个方向的,可郁闷的是运行时,出现重复添加的排行的郁闷

例如:我添加了一个编号为00001的商品要排在排行榜上的第一位,我点击添加后,没有异常;当我添加编号为00002的商品要排在第二位的时候,却出现了00001的商品在排行榜上处在第1和第3的位置,00002处于第2和第4,也就是说程序上重复执行了一次,可我死活也找不出哪里造成的这个结果。请高手帮忙。

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧