asp 注释
<%
bookname=Trim(Request.Form("name"))
booktype=Trim(Request.Form("fl"))
publishing=Trim(Request.Form("cbs"))
money1=trim(Request.Form("jg1"))
money2=trim(Request.Form("jg2"))
date1=Trim(Request.Form("s1"))
date2=Trim(Request.Form("s2"))
date3=Trim(Request.Form("s3"))
date11=Trim(Request.Form("j1"))
date22=Trim(Request.Form("j2"))
date33=Trim(Request.Form("j3"))
date111=date1&"-"&date2&"-"&date3
date222=date11&"-"&date22&"-"&date33
set conn=server.CreateObject("adodb.connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("123.mdb")
set rs=server.CreateObject("adodb.recordset")
dim sql,myrecordset
sql="select * from tushuxinxi where 1 "
if bookname<>"" then
sql=sql+" and bookname like '%"&bookname&"%'"
end if
if booktype<>"" then
sql=sql+" and booktype ='"&booktype&"'"
end if
if publishing<>"" then
sql=sql+" and publishing like '%"&publishing&"%'"
end if
if money1<>""and money2<>"" then
sql=sql+" and bookmoney>="&money1&" and bookmoney<="&money2&""
end if
if date1<>""and date2<>"" then
sq1=sq1+" and pdatebetween '"&date111&"' and '"&date222&"'order by id desc"
end if
rs.open sql,conn,1,3
%>
<%
rs.pagesize=10
pagecount1=rs.pagecount
if request.querystring("pagenum")=0 or request.querystring("pagenum")="" then
pagenum=1
else
pagenum=trim(request("pagenum"))
rs.absolutepage=trim(request("pagenum"))
end if
%>
<%'分页实现
response.write "总共"&pagecount1&"页,当前"&pagenum&"/"&pagecount1&", <a href=chaxun11.asp?pagenum=1&bookname="&bookname&"&booktype="&booktype&"&publishing="&publishing&"&money1="&money1&"&money2="&money2&"&date1="&date1&"&date2="&date2&"&date3="&date3&"&date11="&date11&"&date22="&date22&"&date33="&date33&">首页</a>"
%>
<%
if pagenum>1 then
response.write "<a href=chaxun11.asp?pagenum="&(pagenum-1)&"&bookname="&bookname&"&booktype="&booktype&"&publishing="&publishing&"&money1="&money1&"&money2="&money2&"&date1="&date1&"&date2="&date2&"&date3="&date3&"&date11="&date11&"&date22="&date22&"&date33="&date33&">上一页</a> "
else
response.write "上一页 "
end if
if pagenum < trim(pagecount1) then
response.write "<a href=chaxun11.asp?pagenum="&(pagenum+1)&"&bookname="&bookname&"&booktype="&booktype&"&publishing="&publishing&"&money1="&money1&"&money2="&money2&"&date1="&date1&"&date2="&date2&"&date3="&date3&"&date11="&date11&"&date22="&date22&"&date33="&date33&">下一页</a> "
else
response.write "下一页"
end if
%>
<%
response.write "<a href=chaxun11.asp?pagenum="&pagecount1&"&bookname="&bookname&"&booktype="&booktype&"&publishing="&publishing&"&money1="&money1&"&money2="&money2&"&date1="&date1&"&date2="&date2&"&date3="&date3&"&date11="&date11&"&date22="&date22&"&date33="&date33&">尾页</a>"
%>
追问:能更加详细吗能在仔细说明吗?有赏金了,只要全部注释出来就OK了!
答案:<%
bookname=Trim(Request.Form("name"))'取得from表单中的值
booktype=Trim(Request.Form("fl"))
publishing=Trim(Request.Form("cbs"))
money1=trim(Request.Form("jg1"))
money2=trim(Request.Form("jg2"))
date1=Trim(Request.Form("s1"))
date2=Trim(Request.Form("s2"))
date3=Trim(Request.Form("s3"))
date11=Trim(Request.Form("j1"))
date22=Trim(Request.Form("j2"))
date33=Trim(Request.Form("j3"))
date111=date1&"-"&date2&"-"&date3'把日期组合成2010-01-20样式
date222=date11&"-"&date22&"-"&date33
set conn=server.CreateObject("adodb.connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="&server.mappath("123.mdb")'数据库连接
set rs=server.CreateObject("adodb.recordset")
dim sql,myrecordset
'以下为对字符进行判断来得来SQL语句
sql="select * from tushuxinxi where 1 "
if bookname<>"" then
sql=sql+" and bookname like '%"&bookname&"%'"
end if
if booktype<>"" then
sql=sql+" and booktype ='"&booktype&"'"
end if
if publishing<>"" then
sql=sql+" and publishing like '%"&publishing&"%'"
end if
if money1<>""and money2<>"" then
sql=sql+" and bookmoney>="&money1&" and bookmoney<="&money2&""
end if
if date1<>""and date2<>"" then
sq1=sq1+" and pdatebetween '"&date111&"' and '"&date222&"'order by id desc"
end if
rs.open sql,conn,1,3'执行SQL语句,打开记录集
%>
<%
rs.pagesize=10'分页中每页显示10条信息
pagecount1=rs.pagecount'pagecount1等于总页数
if request.querystring("pagenum")=0 or request.querystring("pagenum")="" then'对页数值进行判断,当为0或空时空为第一页
pagenum=1
else'当页数值不为0和空时则等于页数值
pagenum=trim(request("pagenum"))
rs.absolutepage=trim(request("pagenum"))'rs.absolutepage为当前页
end if
%>
<%'分页实现,输出:总共X页,当前X/Y
response.write "总共"&pagecount1&"页,当前"&pagenum&"/"&pagecount1&", <a href=chaxun11.asp?pagenum=1&bookname="&bookname&"&booktype="&booktype&"&publishing="&publishing&"&money1="&money1&"&money2="&money2&"&date1="&date1&"&date2="&date2&"&date3="&date3&"&date11="&date11&"&date22="&date22&"&date33="&date33&">首页</a>"
%>
<%
if pagenum>1 then'当页数值大于1,则输出上一页,有连接
response.write "<a href=chaxun11.asp?pagenum="&(pagenum-1)&"&bookname="&bookname&"&booktype="&booktype&"&publishing="&publishing&"&money1="&money1&"&money2="&money2&"&date1="&date1&"&date2="&date2&"&date3="&date3&"&date11="&date11&"&date22="&date22&"&date33="&date33&">上一页</a> "
else'当页数值小于1,则输出上一页,无连接,因为当前页就是第一页
response.write "上一页 "
end if
if pagenum < trim(pagecount1) then'当前页数值小于总共页数时,则输出下一页,有连接
response.write "<a href=chaxun11.asp?pagenum="&(pagenum+1)&"&bookname="&bookname&"&booktype="&booktype&"&publishing="&publishing&"&money1="&money1&"&money2="&money2&"&date1="&date1&"&date2="&date2&"&date3="&date3&"&date11="&date11&"&date22="&date22&"&date33="&date33&">下一页</a> "
else'当前页数值大于等于总页数时,则输出下一页,但无连接,因为当前页就为最后一面
response.write "下一页"
end if
%>
<%'输出尾页
response.write "<a href=chaxun11.asp?pagenum="&pagecount1&"&bookname="&bookname&"&booktype="&booktype&"&publishing="&publishing&"&money1="&money1&"&money2="&money2&"&date1="&date1&"&date2="&date2&"&date3="&date3&"&date11="&date11&"&date22="&date22&"&date33="&date33&">尾页</a>"
%>
其他:一没悬赏二没说明,神会来帮你
上一个:asp+sql 如何有效的防止sql注入
下一个:ASP 提示 缺少对象: 'clipboardData'