多条件组合查询,分页问题(点下页后,无记录出来,但地址栏上是正常的)
多条件组合查询,分页问题(点下页后,无记录出来,但地址栏上是正常的)代码如下
程序代码:
<html> <head> <title>仪表查询输入查询内容页面</title> <meta name="GENERATOR" content="Microsoft FrontPage 6.0"> <link rel="stylesheet" type="text/css" href="css.css"> </head> <body> <table width='100%' border='0' cellpadding='3' cellspacing='3' align=center> <td height="25" bgcolor="#0080C0"><p align="center"><b><font color="#FFFFFF" style="font-size: 9pt"> 仪表月工作票自定义查询</font></b></td> </tr> <tr> <td height="100"><p align="center"> <form method="POST" target="mainFrame" action="search.asp"> <p align="center"> 选择分厂: <select name ="KS_fcmc" class="smallInput"> <option value=""></option> <option value="顺丁橡胶厂">顺丁橡胶厂</option> <option value="甲乙酮厂">甲乙酮厂</option> <option value="醇酮厂">醇酮厂</option> <option value="己二酸厂">己二酸厂</option> <option value="公用工程">公用工程</option> <option value="聚丙烯厂">聚丙烯厂</option> <option value="沥青厂">沥青厂</option> <option value="输气厂">输气厂</option> </select> 故障现象: <input type="text" name="KS_gzxx" size="18" class="smallInput" maxlength="255"> 工作票月份: <input type="text" name="KS_tcsj" size="18" class="smallInput" maxlength="255">请按照“2013-1”来填写! </p> <p align="center"> <input type="submit" value="开始查询 " name="action2" > <input type="reset" value="重新填写" name="action2" > </p> </form></td> </tr> </table> <p> <a href="admin/login.asp" target="_blank"></a></p> </div> </body> </html> 下面是搜索和显示页面 <!--#include file="conn2.asp" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>工作票查询系统</title> <link href="admin/css.css" rel="stylesheet" type="text/css"> <style type="text/css"> <!-- .STYLE1 { color: #000000; font-weight: bold; } .STYLE2 {color: #003300} .STYLE3 { color: #FF0000; font-weight: bold; } --> </style> </head> <body> <center><div> <% sExport = Request.QueryString("export") ' Load Export Request If sExport = "html" Then ' Printer Friendly End If If sExport = "excel" Then Response.ContentType = "application/vnd.ms-excel" Response.AddHeader "Content-Disposition", "attachment; filename=ht.xls" End If %> <script LANGUAGE="javas cript"> <!-- function AutomateExcel() { // Start Excel and get Application object. var oXL = new ActiveXObject("Excel.Application"); // Get a new workbook. var oWB = oXL.Workbooks.Add(); var oSheet = oWB.ActiveSheet; var table = document.all.tb1; var hang = table.rows.length; var lie = table.rows(0).cells.length; // Add table headers going cell by cell. for (i=0;i<hang;i++) { for (j=0;j<lie;j++) { oSheet.Cells(i+1,j+1).value = table.rows(i).cells(j).innerText; } } oXL.Visible = true; oXL.UserControl = true; } //--> </script> <% function GetValidateInt(i, max, min) if i < min then GetValidateInt = CInt(min) elseif i > max then GetValidateInt = CInt(max) else GetValidateInt = CInt(i) end if end function %> <% filename = "search.asp" dim KS_gzxx dim KS_tcsj dim KS_fcmc dim ThisPageNum dim rs dim param dim kind dim bh KS_fcmc = Request("KS_fcmc") KS_gzxx = Request("KS_gzxx") KS_tcsj = Request("KS_tcsj") url="" sql="select * from KS_Form_gzptj where 1=1" if KS_gzxx<>"" then url=url&"&KS_gzxx="&KS_gzxx sql=sql&" and KS_gzxx like '%"&KS_gzxx&"%'" end if if KS_fcmc<>"" then url=url&"&KS_fcmc="&KS_fcmc sql=sql&" and KS_fcmc like '%"&KS_fcmc&"%'" end if if KS_tcsj<>"" then url=url&"&KS_tcsj="&KS_tcsj sql=sql&" and KS_tcsj like '%"&KS_tcsj&"%'" end if session("urls")=url url=session("urls") sql=sql+ "order by id desc" set rs = Server.CreateObject("ADODB.RecordSet") rs.open sql, conn, 1,1 rs.pagesize = 10 if rs.eof then response.write "<h1>没有查询到相关记录</h1><br>" response.end end if if request.querystring("pg") = "" then ThisPageNum = GetValidateInt(CInt(i), CInt(rs.pageCount), 1) end if ThisPageNum = ThisPageNum - 1%><% if not rs.eof then i = ThisPageNum * rs.PageSize j = i + rs.PageSize rs.move i, adBookmarkFirst else end if do while not rs.eof and not rs.bof and i < j %> <% i = i + 1 rs.movenext loop %> 第<%=ThisPageNum+1%>页/共<%=rs.PageCount%>页- <%if (ThisPageNum+1) <= 1 then %> 上一页 <%else%> <a href="<%=filename%>?pg=<%=((ThisPageNum+1)-1)%><%=url%>">上一页</a> <%end if%> <%if (ThisPageNum+1) >= rs.PageCount then %> 下一页 <%else%> <a href="<%=filename%>?pg=<%=((ThisPageNum+1)+1)%><%=url%>">下一页</a> <%end if%> <body topmargin="0"> <br> <p align=center><span class="STYLE2"><font color="#FF0000"><td colspan=12 bgcolor="<%=m_top%>"><p align=center height=25>共 <%=total%> 项 <a href="search.asp?export=excel"><img src="mm/exportxls.gif" width="16" height="16" border="0"></a><input type="hidden" name="out_excel" onClick="AutomateExcel();" value="导出到excel" class="notPrint"> <br> <br><table align=center border="1" width="100%" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="<%=border%>" id="tb1"> <tr align="center" height=20> <td width="8%">仪表位号</td> <td width="18%">故障现象</td> <td width="20%">故障原因</td> <td width="22%">作业内容</td> <td width="8%">作业人</td> <td width="10%">装置单元</td> <td width="9%">提出时间</td> <td width="10%">分厂名称</td> </tr> <tr align="center" height=20> <td width="8%" align="center" bgcolor="#FFFFFF"><%=rs("KS_ybwh")%> </td> <td width="18%" align="center" bgcolor="#FFFFFF"><%=rs("KS_gzxx")%></td> <td width="20%" align="center"><%=rs("KS_gzyy")%></td> <td width="22%" align="center"><%=rst("KS_cljg")%></td> <td width="8%"><%=rs("KS_zyr")%></td> <td width="10%"><%=rs("KS_zzmc")%></td> <td width="9%"><%=rs("KS_tcsj")%></td> <td width="10%"><%=rs("KS_fcmc")%></td> </tr> </tr></table> <% rs.MoveNext end if next rs.close %> </body> <SCRIPT LANGUAGE="JavaScript"> function saveCode(obj) { var winname = window.open('', '_blank', 'top=10000'); var strHTML = document.all.tb1.innerHTML; winname.document.open('text/html', 'replace'); winname.document.writeln(strHTML); winname.document.execCommand('saveas','','excel.xls'); winname.close(); } </SCRIPT> <p class="STYLE2"> </p> <p class="STYLE2"><a href="main.asp" class="STYLE3">没有相关信息请返回</a></p> </div> </center> </body> </html>
[ 本帖最后由 wangzhi8515 于 2013-1-16 18:03 编辑 ]