asp多条件模糊查询遇到问题,请高手帮忙

2024-12-23 02:30:37
推荐回答(2个)
回答1:

<%
dim pd
pd=" where"
area=request("area")
star=request("star")
if area="" and star <>"" then
pd=pd+"bid='"&area&"'"
elseif area<>"" and star="" then
pd=pd+"xid='"&star&"'"
else
pd=""
end if
set rs=server.createobject("adodb.recordset")
sql="select * from jianli "&pd

rs.open sql,conn,1,1
if rs.eof then
response.write "No related comments at present!"
else
rs.PageSize =10 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if
end if
i=1
while not rs.eof and i<=rs.pagesize

%>

回答2:

sql="select * from jianli where bid='"&area&"'"
if strbid<>"" then
sql=sql+" and bid='"&area&"'"
end if
if strxid<>"" then
sql=sql+" and xid='"&star&"'"
end if

这段改成

sql="select * from jianli where"
if strbid<>"" and strxid<>"" then
sql=sql+" bid='"&area&"' and xid='"&star&"'"
end if
if strbid<>"" and strxid = "" then
sql=sql+" bid='"&area&"'"
end if
if strxid<>"" and strbid = "" then
sql=sql+" xid='"&star&"'"
end if

MSN:guweibeat@hotmail.com 我在日本,有问题上MSN。