已经实现了,程序如下:
<!--#include file="inc/conn.asp"-->
<!--#include file="include/head.asp"-->
<%
set rs=server.CreateObject("adodb.recordset")
sql="select * from orders where id="&request("id")
rs.open sql,conn,1,3
set rs3=server.CreateObject("adodb.recordset")
sql3="select * from parts order by id desc"
rs3.open sql3,conn,1,3
%>
<table width=1500 border=0 cellspacing=1 cellpadding=1 align=center bgcolor=#000000>
<tr align=center bgcolor=#ffffff>
<td colspan=2><%=rs("orderno")%>订单报表</td>
<%
i=date()-rs("start")
for j=0 to i
%>
<td><%=rs("start")+j%></td>
<%
next
%>
<td>剩余数量</td>
</tr>
<%
do while not rs3.eof
manage=rs3("productid")
dst="|"+trim(rs("productid"))+"|"
if instr(manage,dst)>0 then
%>
<tr bgcolor=#ffffff>
<td><%=rs3("typeno")%></td><td><%=rs3("name")%></td>
<%
dsum=0
for j=i to 0 step -1
set rs2=server.CreateObject("adodb.recordset")
sql2="select * from track where orderid="&request("id")&" and typeid="&rs3("id")&" and marktime=date()-"&j //这里是关键
rs2.open sql2,conn,1,3
if rs2.bof and rs2.eof then jsum=0 else jsum=rs2("sum") end if
%>
<td align=right><%=jsum%></td>
<%
dsum=dsum+jsum
next
%>
<td align=right><%=rs("plan")*rs3("ruler")-dsum%></td>
</tr>
<%
end if
rs3.movenext
loop
rs2.close
set rs2=nothing
rs3.close
set rs3=nothing
rs.close
set rs=nothing
%>
</table>
感谢大家的帮助,给了我很多启发
[此贴子已经被作者于2006-7-28 14:02:52编辑过]