<%if Session("weight")=0 then 
Response.Redirect "error.asp?cause=4"
 end if

%>

<%
	
nickname=Request("nickname")
pub_time=Request("pub_time")
sex=Request("sex")
agefrom=Request("agefrom")
ageto=Request("ageto")
heightfrom=Request("heightfrom")
heightto=Request("heightto")
weightfrom=Request("weightfrom")
weightto=Request("weightto")
education=Request("education")
work_province=Request("work_province")
work_city=Request("work_city")
income=Request("income")
house=Request("house")
%>
<%	if nickname<>"" then
	sql="select user.*,marry_public.* from user,marry_public where  marry_public.user_name=user.user_name and user.nickname='"&nickname&"'"
	sql=sql&" ORDER BY user.weight DESC , user.photo DESC"
	session("sql")=sql
	Response.Redirect "my_marry_public.asp?searched=1"
	end if


	'//////////////////////////
dim sql

	sql="select user.*,marry_public.* from user,marry_public,user_info where  marry_public.user_name=user.user_name and user_info.user_name=user.user_name"
'////////
if pub_time<>"" then
if pub_time="1" then
	temp_time=dateadd("ww",-1,date)
elseif pub_time="2" then
	temp_time=dateadd("m",-1,date) 
elseif pub_time="3" then
	temp_time=dateadd("m",-3,date) 
end if
	sql=sql&" and pub_time>=#"&temp_time&"#"
end if	
if sex<>"" then
	sql=sql&" and sex='"&sex&"'"
end if
if Request("agefrom")<>"" and Request("ageto")<>"" then
if Request("agefrom")<Request("ageto") then
	min_byear=year(date)-Request("ageto")
	max_byear=year(date)-Request("agefrom")
else
	min_byear=year(date)-Request("agefrom")
	max_byear=year(date)-Request("ageto")
end if
sql=sql&" and byear>'"&min_byear&"'"
sql=sql&" and byear<'"&max_byear&"'"
end if
'//////////////////////////////
if Request("heightto")<>"" and Request("heightfrom")<>"" then
if heightfrom>heightto then
	
heightfrom=Request("heightto")
heightto=Request("heightfrom")
end if
sql=sql&" and user_info.height>="& heightfrom

sql=sql&" and user_info.height<="& heightto
end if
'///////////////////////
'//////////////////////////////
if Request("weightto")<>"" and Request("weightfrom")<>"" then
if weightfrom>weightto then
	
weightfrom=Request("weightto")
weightto=Request("weightfrom")
end if
sql=sql&" and user_info.weight>="& weightfrom

sql=sql&" and user_info.weight<="& weightto
end if
'///////////////////////
if income<>"" then
	sql=sql&" and salary='"&income&"'"
end if
if education<>"" then
	sql=sql&" and education='"&education&"'"
end if
if work_province<>"" then
	sql=sql&" and work_province='"&work_province&"'"
end if
if work_city<>"" then
	sql=sql&" and work_city='"&work_city&"'"
end if

if house<>"" then
	sql=sql&" and house='"&house&"'"
end if
sql=sql&" ORDER BY user.weight DESC , user.photo DESC"
session("sql")=sql
Response.Redirect "my_marry_public.asp"
%><p><%=session("sql")%></p>
