解决asp搜索问题

来源:百度知道 编辑:UC知道 时间:2024/05/30 09:36:21
<%

sql="select * from games where mytype='"& mytype &"'"

if (sort_id<>"" and nsort_id<>"" and nnsort_id<>"" and selltype<>"") then
sql=sql & " and sort_id="& sort_id &" and nsort_id="& nsort_id &" and nnsort_id="& nnsort_id &" and selltype='"& selltype &"'"
end if
if (sort_id<>"" and nsort_id<>"" and nnsort_id<>"") then
sql=sql & " and sort_id="& sort_id &" and nsort_id="& nsort_id &" and nnsort_id="& nnsort_id
end if
if (sort_id<>"" and nsort_id<>"") then
sql=sql & " and sort_id="& sort_id &" and nsort_id="& nsort_id
end if
if ( sort_id<>"") then
sql=sql & " and sort_id="& sort_id

<%
function seach(tab,fie,num)'tab为检索的数据表,fie为检索的字所有字段,num为检索的数据
tj=""
str="select * from ["&tab&"]"
zd=split(fie,",")
sj=split(num,",")
for j=0 to ubound(sj)
if sj(j)<>"" then
tj=" where "
end if
next
str=str&tj
for i=0 to ubound(sj)
if i=0 then
if sj(i)<>"" then
str=str&zd(i)&" like '%"&sj(i)&"%'"
end if
else
if sj(i)<>"" then
for w=0 to i-1
if sj(w)<>"" then
lj=" and "
end if
next
str=str&lj&zd(i)&" like '%"&sj(i)&"%'"
end if
end if
next
seach=str
end function
%>

<%
sql="select * from games where mytype='"& mytype &"'"
if sort_id > "" a