程序地址:www.kinets.com/gongpiao
查询的时候不选择时间段没有问题,选择时间段查询后显示正常,但点下一页往后翻页的时候出现的结果确是全部时间段的数据。
我实在是搞不懂问题出在哪了,望知道的GG、JJ指点一下。
下面的是代码
<!--#include file="conn.asp"-->
<html><head><title>工票管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../images/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<form name="form2" method="post" action="user01manage.asp">
<div align="center">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td>
<div align="center">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" style="border-collapse: collapse">
<tr>
<td height="30" align="center" bgcolor="#CCCCCC">工票状态:
<select size="1" name="ztname" style="width:65">
<%
set ztrs=conn.execute("select * from zhuanti order by ztorder")
do while not ztrs.eof
%>
<option selected value=<%=ztrs("ztname")%>><%=ztrs("ztname")%></option>
<%
ztrs.movenext
loop
set ztrs=nothing
%>
</select>
起始:
<select name="year1" size="1">
<%for i=2006 to year(date())%>
<option value="<%=i%>"><%=i%> </option>
<%next%>
</select>
年
<select name="month1" size="1">
<option value="01" selected>01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
月
<select name="day1" size="1">
<option value=01 selected>01</option>
<option value=02>02</option>
<option value=03>03</option>
<option value=04>04</option>
<option value=05>05</option>
<option value=06>06</option>
<option value=07>07</option>
<option value=08>08</option>
<option value=09>09</option>
<option value=10>10</option>
<option value=11>11</option>
<option value=12>12</option>
<option value=13>13</option>
<option value=14>14</option>
<option value=15>15</option>
<option value=16>16</option>
<option value=17>17</option>
<option value=18>18</option>
<option value=19>19</option>
<option value=20>20</option>
<option value=21>21</option>
<option value=22>22</option>
<option value=23>23</option>
<option value=24>24</option>
<option value=25>25</option>
<option value=26>26</option>
<option value=27>27</option>
<option value=28>28</option>
<option value=29>29</option>
<option value=30>30</option>
<option value=31>31</option>
</select>
日 截至:
<select name="year2" size="1">
<%for i=2006 to year(now())%>
<option value="<%=i%>" <%if year(now())=i then%>selected<%end if%>><%=i%></option>
<%next%>
</select>
年
<select name="month2">
<% if month(date())<10 then %>
<option selected value="0<%=month(date())%>">0<%=month(date())%>
<%else%>
<option selected value="<%=month(date())%>"><%=month(date())%>
<%end if%>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
月
<select name="day2">
<% if day(date())<10 then %>
<option selected value="0<%=day(date())%>">0<%=day(date())%>
<%else%>
<option selected value="<%=day(date())%>"><%=day(date())%>
<%end if%>
<option value=01>01</option>
<option value=02>02</option>
<option value=03>03</option>
<option value=04>04</option>
<option value=05>05</option>
<option value=06>06</option>
<option value=07>07</option>
<option value=08>08</option>
<option value=09>09</option>
<option value=10>10</option>
<option value=11>11</option>
<option value=12>12</option>
<option value=13>13</option>
<option value=14>14</option>
<option value=15>15</option>
<option value=16>16</option>
<option value=17>17</option>
<option value=18>18</option>
<option value=19>19</option>
<option value=20>20</option>
<option value=21>21</option>
<option value=22>22</option>
<option value=23>23</option>
<option value=24>24</option>
<option value=25>25</option>
<option value=26>26</option>
<option value=27>27</option>
<option value=28>28</option>
<option value=29>29</option>
<option value=30>30</option>
<option value=31>31</option>
</select>
工票号:
<input name="keyword" type="text" id="keyword" size="5"> <input type="submit" name="Submit" value="查 询">
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td height="25" background="bg1.gif"><table width="800" border="0" cellpadding="0" cellspacing="1" bordercolor="#CCCCCC" style="border-collapse: collapse">
<%'开始分页
Const MaxPerPage=6
dim totalPut
dim CurrentPage
dim TotalPages
dim j
dim sql
if Request("page")<>"" then
currentPage=Cint(request("page"))
else
currentPage=1
end if
set rs=server.CreateObject("adodb.recordset")
sql="select * from soft where aaa=0 "
ztname=trim(request("ztname"))
keyword=trim(request("keyword"))
startdate=Request("year1")&Request("month1")&Request("day1")
enddate=Request("year2")&Request("month2")&Request("day2")
scontent=request("scontent")
if ztname<>"" then
if ztname<>"0" then
sql=sql&" and ztname like '%"&ztname&"%'"
end if
end if
if startdate<>"" then
sql=sql&" and fdate>="&startdate
end if
if enddate<>"" then
sql=sql&" and fdate<="&enddate
end if
if keyword<>"" then
sql=sql&" and scontent like '%"&keyword&"%' "
end if
sql=sql&" order by fdate desc "
rs.open sql,conn,1,1
if err.number<>0 then
response.write "暂无符合条件的工票!"
end if
if rs.eof And rs.bof then
Response.Write "<p align='center' > 暂无符合条件的工票!</p>"
else
totalPut=rs.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage totalput,MaxPerPage,"user01manage.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"user01manage.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"user01manage.asp"
end if
end if
end if
sub showContent
dim i
i=0%>
<%do while not rs.eof%>
<tr>
<td width="800" height="15"><table width="800" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
<tr>
<td bgcolor="#FFFFFF">编号:<%=rs("newsnum")%> 工票状态:<%=rs("ztname")%> 完成时间:<%=rs("fdate")%></td>
</tr>
</table></td>
</tr>
<tr>
<td height="15" align="right" bgcolor="#CCCCCC"> <font size="2"><b>
<%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing%>
<font color="#0000FF"> </font> </b>
<%
End Sub
Function showpage(totalnumber,maxperpage,filename)
Dim n
If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If
Response.Write "<p align='center' > "
If CurrentPage<2 Then
Response.Write "<font size=2>首页 上一页</font> "
Else
Response.Write "<a href="&filename&"?page=1"&"&ztname=" & ztname & "&startdate=" & startdate & "&enddate=" & enddate & "&keyword="& keyword & "&scontent=" & scontent & " >首页</a> "
Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&ztname=" & ztname & "&startdate=" & startdate & "&enddate=" & enddate & "&keyword="& keyword & "&scontent=" & scontent & " >上一页</a> "
End If
If n-currentpage<1 Then
Response.Write "<font size=2>下一页 尾页</font>"
Else
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)& "&ztname=" & ztname & "&startdate=" & startdate & "&enddate=" & enddate & "&keyword="& keyword & "&scontent=" & scontent & ">"
Response.Write "下一页</a> <a href="&filename&"?page="&n&"&ztname=" & ztname & "&startdate=" & startdate & "&enddate=" & enddate & "&keyword="& keyword & "&scontent=" & scontent & ">尾页</a>"
End If
Response.Write "<font size=2> 页次:</font><font size=2>"&CurrentPage&"</font><font size=2>/"&n&"页</font> "
End Function
%>
<b> </b> </font></td>
</tr>
</table></td>
</tr>
</table>
</form>
</td>
</body>
</html>