[求助]时间段查询问题
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file = "checkinfoadmin.asp"-->
<!-- #include file="conn.asp" -->
<html>
<style type="text/css">
<!--
.style18 {color: #330000}
-->
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>:::清单:::</title>
<link href="../css/fontsize.css" rel="stylesheet" type="text/css">
<link href="../css/input_form.css" rel="stylesheet" type="text/css">
<link href="../css/inputform1.css" rel="stylesheet" type="text/css">
<link href="../css/selectform.css" rel="stylesheet" type="text/css">
<link href="../css/inputform2.css" rel="stylesheet" type="text/css">
<link href="../css/inputform3.css" rel="stylesheet" type="text/css">
<link href="../css/inputform3.css" rel="stylesheet" type="text/css">
<link href="../css/link.css" rel="stylesheet" type="text/css">
<link href="../css/buttoncss.css" rel="stylesheet" type="text/css">
<link href="../css/inputchaxun.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-image: url(../pictures/0343.jpg);
}
.style6 {color: #66CCFF}
.style7 {
color: #330000;
font-style: italic;
}
.style8 {font-size: 12pt}
.style10 {
color: #330000;
font-size: 16px;
}
.style11 {color: #0000FF}
.style13 {font-size: 14px}
.style15 {font-size: 16px}
.style19 {color: #990000}
.style21 {
color: #0000FF;
font-size: 18px;
font-weight: bold;
font-style: italic;
}
.style23 {
color: #66CCFF;
font-weight: bold;
font-style: italic;
}
.style25 {color: #0000FF; font-size: 18px; font-weight: bold; }
.style26 {color: #660000; }
-->
</style></head>
<body bgcolor="#6699cc" >
<tr>
<td width="100%" height="71" background="../pictures/0343.jpg"><font color="#660000"> :::欢迎您使用本查询模块:::请输入查询条件...</font> </td>
</tr>
<tr> </td></tr>
<tr>
<td background="../pictures/0343.jpg"><div align="right">
<table width="760" height="27" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#333300" bgcolor="#FFFFFF" class="fontsize" style="border-collapse: collapse">
<form name="chaxun_form" action="fineschool.asp" method="post" >
<tr align="center" valign="middle">
<td width="7%" height="23" bgcolor="#66CCCC"> <div align="center">公司</div></td>
<td width="9%"><div align="center"><font size="2">
<input name="school_chaxun" type="text" id="school_chaxun2" onMouseOver="this.focus();" size="5">
</font></div></td>
<td width="7%" bgcolor="#66CCCC"> <div align="center"><font size="2">单号
</font></div></td>
<td width="16%" bgcolor="#FFFFFF"><div align="center">
<input name="num_of_grade_chaxun" type="text" id="num_of_grade_chaxun"onMouseOver="this.focus();" size="11">
</div></td>
<td width="7%" bgcolor="#66CCCC"> <div align="center">起期</div></td>
<td width="12%">
<div align="center">
<input name="starttime_chaxun" type="text" id="starttime_chaxun" onMouseOver="this.focus();" value="<%=date()-30%>" size="8">
</div></td>
<td width="7%" bgcolor="#66CCCC"> <div align="center">终期</div></td>
<td width="12%">
<div align="center">
<input name="endtime_chaxun" type="text" id="endtime_chaxun" onMouseOver="this.focus();" value="<%=date()%>" size="8">
</div></td>
<td width="7%" bgcolor="#66CCCC"> <div align="center"><font size="2">类型</font></div></td>
<td width="6%"> <div align="center"><font size="2">
<input name="num_of_classes_chaxun" type="text" id="num_of_classes_chaxun"onMouseOver="this.focus();" size="2">
</font></div></td>
<td width="7%" bgcolor="#66CCCC">备注</td>
<td width="14%" bgcolor="#66CCCC"><font size="2">
<input name="num_of_bz_chaxun" type="text" id="num_of_bz_chaxun2" onMouseOver="this.focus();" size="5">
</font></td>
<td width="14%" bgcolor="#66CCCC">
<div align="center">
<input name="chaxun" type="submit" id="chaxun5" value="我要查询">
</div></td>
</tr>
</form>
</table>
</div>
</td>
</tr>
<tr>
<td background="../pictures/0343.jpg"> </td>
</tr>
<tr>
<td background="../pictures/0343.jpg"><div align="right"><span class="style13">办理人员:<span class="style19"><%=session("name")%></span></span><span class="style19"></span><span class="style18"></span> </div></td>
</tr>
<tr>
<td background="../pictures/0343.jpg"><div align="left"><font color="#660000"> 下表是查询结果清单:</font></div></td>
</tr>
<tr>
<td height="141" background="../pictures/0343.jpg">
<table width="760" border="2" align="center" cellpadding="0" cellspacing="0" bordercolor="#333300" bgcolor="#66CCCC" style="border-collapse: collapse">
<tr align="center" valign="middle" bgcolor="#FFCCCC" class="fontsize">
<td width="15%" height="27">
<div align="center"><strong>发件公司</strong></div></td>
<td width="9%"><div align="center"><strong>发件人</strong></div></td>
<td width="9%">
<div align="center"><strong>发件日期</strong></div></td>
<td width="13%">
<div align="center"><strong>单号</strong></div></td>
<td width="5%">
<div align="center"><strong>类型</strong></div></td>
<td width="5%">
<div align="center"><strong>重量</strong></div></td>
<td width="5%">
<div align="center"><strong>金额</strong></div></td>
<td width="15%">
<div align="center"><strong>收件公司地址</strong></div></td>
<td width="9%">
<div align="center"><strong>收件人</strong></div></td>
<td width="11%">
<div align="center"><strong>备注</strong></div></td>
</tr>
<%
set rs=server.CreateObject("adodb.recordset")
if request("starttime_chaxun")="" and request("endtime_chaxun")="" then
sql= "select * from school where school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc"
else
sql="select * from school where num_of_riqi between #"&cdate(request("starttime_chaxun"))&"# and #"&cdate(request("endtime_chaxun"))&"# and school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc "
end if
rs.open sql,conn,1,1
if rs.recordcount <> 0 then
rs.movefirst
do while not rs.eof
%>
<tr bgcolor="#66CCCC" class="fontsize">
<td><div align="center"><%=rs("school")%></div></td>
<td><div align="center"><%=rs("num_of_fjr")%></div></td>
<td><div align="center"><%=rs("num_of_riqi")%></div></td>
<td><div align="center"><%=rs("num_of_grade")%></div></td>
<td><div align="center"><%=rs("num_of_classes")%></div></td>
<td height="28"><div align="center"><%=rs("num_of_students")%></div></td>
<td><div align="center"><%=rs("num_of_je")%></div></td>
<td><div align="center"><%=rs("num_of_fjd")%></div></td>
<td><div align="center"><%=rs("num_of_sjr")%></div></td>
<td><div align="center" class="style26"><%=rs("num_of_bz")%></div></td>
</tr>
<%
rs.movenext
loop
else
%>
<tr class="fontsize">
<td height="24" colspan="7" bgcolor="#66CCCC"><div align="center" class="style11"><font size="2">对不起,没查询到符合您需要的信息!</font></div></td>
</tr>
<%
end if
%>
</table>
<p> <span class="style6"><span class="style7 style15">合计: 总件数为:<span class="style25"><%=rs.recordcount%> </span>件;
<%
dim toutput'设置变量,总重量合计初始值为0
num_of_students=""
toutput=0
set rs=server.CreateObject("adodb.recordset")
if request("starttime_chaxun")="" and request("endtime_chaxun")="" then
sql= "select * from school where school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc"
else
sql="select * from school where num_of_riqi between #"&cdate(request("starttime_chaxun"))&"# and #"&cdate(request("endtime_chaxun"))&"# and school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc "
end if
rs.open sql,conn,1,1
if not rs.eof then
%>
<%
while not rs.eof
if num_of_students<>rs("num_of_students") then '写入重量
num_of_students=rs("num_of_students")
toutput=toutput+0
%>
<%
end if%>
<%
toutput=toutput+(rs("num_of_students"))
'cint 取整数
rs.movenext
if rs.eof then
%>
<%
end if
wend
%>
<%
end if
%>
总重量为:<span class="style25"><%=toutput-0%> </span>KG;
<%
dim toutputa
num_of_je=""
toutputa=0
set rs=server.CreateObject("adodb.recordset")
if request("starttime_chaxun")="" and request("endtime_chaxun")="" then
sql= "select * from school where school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc"
else
sql="select * from school where num_of_riqi between #"&cdate(request("starttime_chaxun"))&"# and #"&cdate(request("endtime_chaxun"))&"# and school like '%"&trim(request("school_chaxun"))&"%'and num_of_classes like '%"&trim(request("num_of_classes_chaxun"))&"%' and num_of_grade like'%"&trim(request("num_of_grade_chaxun"))&"%'and num_of_bz like'%"&trim(request("num_of_bz_chaxun"))&"%' order by num_of_riqi desc "
end if
rs.open sql,conn,1,1
if not rs.eof then
%>
<%
while not rs.eof
if num_of_je<>rs("num_of_je") then '写入重量
num_of_je=rs("num_of_je")
toutputa=toutputa+0
%>
<%
end if%>
<%
toutputa=toutputa+(rs("num_of_je"))
'cint
rs.movenext
if rs.eof then
%>
<%
end if
wend
%>
<%
end if
%>
总金额为:</span></span><span class="style21"><%=toutputa-0%> </span><span class="style23"><span class="style15 style18"><span class="style11"></em></span></span></span><span class="style10 style8"><strong><span class="style15"><em></em></span></strong><em>元</em></span> </p>
</tr>
<p>
<%
rs.close
set rs = nothing
conn.close
set conn = nothing
%>
</p>
<p> </p>
<p> </p>
<p align="right"><span class="style6"><span class="style7"><span class="style8">:::我的查询</span>:::<span class="style15"></span> </span></span></p>
</body>
</html>我想查询公司名是“某某”在某段时间所发生的事情。但是在时间段的查询出现了错误了。哥们能否详细的给段类似代码的例子为谢!
[此贴子已经被作者于2005-8-17 18:16:17编辑过]