在做asp查询时候 借鉴的一些代码 留个纪念。。。。。。。 <!-- #include file="conn.asp"--> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>套餐延期资料批量查询</title> </head> <body> <% dim sql,RS,area,xy,saler,etime,page,pagecount saler = Trim(request.Form("saler")) area = Trim(request.Form("area")) xy = Trim(request.Form("xy")) etime = Trim(request.Form("etime")) 'area = "" tele = "" product = "" username = "" tc_name = "" byz = "" bs = "" stime ="" etime = "" 'saler = "" 'xy = "" 'uptime = "" Set RS=Server.CreateObject("ADODB.Recordset") sql="SELECT * FROM tc WHERE" If saler<>"" Then sql=sql&" saler='"&saler&"' AND" If area<>"" Then sql=sql&" area='"&area&"' AND" If xy<>"" Then sql=sql&" xy='"&xy&"' AND" If etime<>"" Then sql=sql&" etime<'"&etime&"' AND" if right(sql,5)="WHERE" then sql=left(sql,clng(len(sql))-5) '解决所有参数都为空的情况 if right(sql,3)="AND" then sql=left(sql,clng(len(sql))-3) '去掉参数最后的and sql=sql&" order by number" RS.open sql,Conn1,3,1 RS.PageSize=100 pagecount=RS.PageCount page=int(request.QueryString("page")) if page<=0 then page=1 if request.QueryString("page")="" then page=1 RS.AbsolutePage=page 'if request.form("area")="" and request.form("xy")="" and request.form("saler")="" then 'response.write("请输入查询条件(可模糊查询)") 'response.end 'end if if RS.eof or RS.bof then response.write("<script language='javascript'>alert('没有该用户信息,请返回重新查询');location.href='search1.asp'</script>") response.end else area = RS ("area") tele = RS ("number") product = RS ("product") username = RS ("username") tc_name = RS ("name") byz = RS ("byz") bs = RS ("bs") stime = RS ("stime") etime = RS ("etime") xy = RS ("xy") saler = RS ("saler") uptime = RS ("uptime") reason = RS("reason") end if %> <table id="t1" align="center" width="90%" height="102" border="1" cellspacing="1" bordercolor="#FFFFFF"> <form name="Myform"> <tr style="text-align:center " id="tr1"> <th colspan="14">套餐延期资料批量查询</th> </tr> <tr bgcolor="#99FFFF" style="text-align:center " bordercolordark="#FFCCFF" bordercolorlight="#FFFFFF"> <td>区域</td> <td>号码</td> <td>产品</td> <td>用户名称</td> <td>套餐名称</td> <td>包月值</td> <td>倍数</td> <td>开始时间</td> <td>结束时间</td> <td>是否续约</td> <td>营销人员</td> <td>填报时间</td> </tr> <%for i=1 to RS.PageSize%> <% if RS.EOF then exit for end if %> <tr style="text-align:center " bordercolordark="#FFCCFF" bordercolorlight="#FFFFFF" > <td><%=area %></td> <td><%=tele %></td> <td><%=product %></td> <td><%=username %></td> <td><%=tc_name %></td> <td><%=byz %></td> <td><%=bs %></td> <td><%=stime %></td> <td><%=etime %></td> <td><%=xy %></td> <td><%=saler %></td> <td><%=uptime %></td> </tr> <% RS.movenext next %> </form> </table> <%if page=1 and not page=pagecount then%> <div align="right">第<%=page%>页 <%for i=1 to pagecount%> <a href="info.asp?page=<%=i%>"><%=i%></a> <%next%><a href="info.asp?page=<%=page+1%>">下一页</a> </div> <%elseif page=pagecount and not page=1 then%> <div align="right">第<%=page%>页 <%for i=1 to pagecount%> <a href="info.asp?page=<%=i%>"><%=i%></a> <%next%><a href="info.asp?page=<%=page-1%>">上一页</a> </div> <%elseif page<1 then%><div class="font" align="right"><font color=red>没有任何记录!</font></div> <%elseif page>pagecount then%><div class="font" align="right"><font color=red>没有任何记录!</font></div> <%elseif page=1 and page=pagecount then%> <%else%> <div align="right">第<%=page%>页 <%for i=1 to pagecount%> <a href="info.asp?page=<%=i%>"><%=i%></a> <%next%><a href="info.asp?page=<%=page-1%>">上一页</a> <a href="info.asp?page=<%=page+1%>">下一页</a> </div> <%end if%> </body> </html>
http://user.qzone.qq.com/372806800/blog/1345306209