数组循环问题

gb_m4gic 2009-04-07 05:41:23

<%
Tid=request("Tid")
sid=request("sid")
if sid<>"" or tid<>"" then
%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/check.asp"-->
<%

set rsd=server.createobject("adodb.recordset")
sqld="select * from sale where id="&sid&""
rsd.open sqld,open_conn(),1,1
if rsd.recordcount>0 then
deshes=rsd("did")
num=rsd("num")
numarry=split(num,",")
aryde=split(deshes,",")
end if
rsd.close
set rsd=nothing

%>

<%
function cck(rid)
for i=0 to UBound(aryde)
if cint(aryde(i))=cint(rid) then
numi=numarry(i)
cck2=true
exit for
else
cck2=false
numi=1
end if
next
cck=cck2
end function
%>
<!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>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.STYLE1 {font-size: 12px}
.STYLE4 {
font-size: 12px;
color: #1F4A65;
font-weight: bold;
}

a:link {
font-size: 12px;
color: #06482a;
text-decoration: none;

}
a:visited {
font-size: 12px;
color: #06482a;
text-decoration: none;
}
a:hover {
font-size: 12px;
color: #FF0000;
text-decoration: underline;
}
a:active {
font-size: 12px;
color: #FF0000;
text-decoration: none;
}
.STYLE7 {font-size: 12}

-->
</style>
</head>

<body>
<form name="Dishes" method="post" action="update_save.asp" style="margin:0px;">
<table width="100%" border="0" align="center" cellpadding="0">
<tr>
<td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15" height="30"><img src="../images/tab_03.gif" width="15" height="30" /></td>
<td width="475" background="../images/tab_05.gif"><img src="../images/311.gif" width="16" height="16" /> <span class="STYLE4">添加菜品</span> </td>
<td width="495" valign="bottom" background="../images/tab_05.gif"><span class="STYLE4">
<input name="tableid" value="<%=sid%>" type="hidden"/>
<%=Tid%>号菜单</span></td>
<td width="250" background="../images/tab_05.gif"><table border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td width="60"><table width="87%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="STYLE1"><div align="center">
<input type="checkbox" name="chkall" value="checkbox" onClick="CheckAll(this.form)"/>
</div></td>
<td class="STYLE1"><div align="center">全选</div></td>
</tr>
</table></td>
<td width="60"><table width="90%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="STYLE1"><div align="center"><img src="../images/001.gif" width="14" height="14" /></div></td>
<td class="STYLE1"><div align="center"><a href="#" onclick="Dishes.submit()">确定</a></div></td>
</tr>
</table></td>
</tr>
</table></td>
<td width="16"><img src="../images/tab_07.gif" width="14" height="30" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="9" background="../images/tab_12.gif"> </td>
<td bgcolor="#f3ffe3">
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#c0de98" onmouseover="changeto()" onmouseout="changeback()">
<tr>
<td width="3%" height="25" background="../images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">选择</div></td>
<td width="3%" height="25" background="../images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">序号</div></td>
<td width="24%" height="25" background="../images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">菜品名称</div></td>
<td width="15%" height="25" background="../images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">所属类别</div></td>
<td width="13%" height="25" background="../images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">价格</div></td>
<td width="11%" height="25" background="../images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">折扣</div></td>
<td width="16%" height="25" background="../images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">折后价</div></td>
<td width="15%" height="25" background="../images/tab_14.gif" class="STYLE1"><div align="center" class="STYLE2 STYLE1">分量</div></td>
</tr>

<%
set rs=server.createobject("adodb.recordset")
sql="select * from Dishes order by id asc"
rs.open sql,open_conn(),1,1
recordcount = rs.recordcount
if rs.recordcount>0 then
do while not rs.eof
%>
<tr>
<td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE1">
<input name="Cid" type="checkbox" class="STYLE2" id="Cid" value="<%=rs("id")%>"
<%if cck(rs("id"))=true then
response.Write "checked"
end if
%>
/>
</div></td>
<td height="18" bgcolor="#FFFFFF" class="STYLE2"><div align="center" class="STYLE2 STYLE1"><%=rs("id")%></div></td>
<td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><%=rs("d_name")%></div></td>
<td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1">
<%
set rs1=Server.CreateObject("ADODB.RecordSet")
strSQL1="select * from kind where id="&rs("d_kind")&""
rs1.open strSQL1,Open_conn(),1,1
if rs1.recordcount>0 then
do while not rs1.eof
%>
<%=rs1("kind")%>
<%
rs1.movenext
loop
else
response.Write "<option value=''>暂无菜品</option>"
end if
rs1.close
set rs1=nothing
%>
</div></td>
<td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><%=rs("Price")%>元</div></td>
<td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><%=rs("Discount")*10%>折</div></td>
<td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><%=rs("Dprice")%>元</div></td>
<td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><input type="textbox" size="10" name="num<%=rs("id")%>" id="num<%=rs("id")%>" value="<%=numi%>"/>份</div></td>
</tr>
<%
rs.MoveNext
loop
end if
rs.close
set rs = nothing
%>
...全文
91 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
gb_m4gic 2009-04-07
  • 打赏
  • 举报
回复
没人知道啊?
gb_m4gic 2009-04-07
  • 打赏
  • 举报
回复
数据得到正常。<td height="18" bgcolor="#FFFFFF"><div align="center" class="STYLE2 STYLE1"><input type="textbox" size="10" name="num<%=rs("id")%>" id="num<%=rs("id")%>" value="<%=numi%>"/>份</div></td>这一列。第一行都是为空。
rokerker 2009-04-07
  • 打赏
  • 举报
回复
首先能不能确定
   set rsd=server.createobject("adodb.recordset")                    
sqld="select * from sale where id="&sid&""
rsd.open sqld,open_conn(),1,1

里面的 "select * from sale where id="&sid&""执行后可以得到数据

然后你的第一栏分量是指的哪里呀
gb_m4gic 2009-04-07
  • 打赏
  • 举报
回复
上面的问题是,每次循环后获得的第一栏分量里面总是为空。

28,390

社区成员

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

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