青龙侍上by月佩环:如何用asp+access实现课程表查询

来源:百度文库 编辑:高考问答 时间:2024/05/04 05:37:14
如何用asp+access实现班级\课程\教师\教室\周次 进行查询,其中有些条件可不添,最好是分页的,谢谢了

<form name=form1 action=UserList.asp method=post target=_self>
<tbody>
<tr>
<td class=style5 height=30> 性别
<input name="sex" type="radio" value="男"> <img src="images/man.gif" width="8" height="12" hspace="1" vspace="1">
<input name="sex" type="radio" value="女" checked> <img src="images/women.gif" width="8" height="12" hspace="1" vspace="1">

年龄:
<select name=age_up>
<option value="0" selected>选择</option>
<option value=18>18</option>
<option
value=19>19</option>
<option
value=20>20</option>
<option
value=21>21</option>

</select>

<select name=age_down>
<option value="0" selected>选择</option>
<option value=18>18</option>
<option value=19>19</option>

</select>
身高:
<select
name=height_up>
<option value="0" selected>选择</option>
<option value=150>150</option>
<option
value=155>155</option>

</select>
照片
<input type=checkbox name="photo" value="yes">
<input name="submitok" type=hidden id="submitok" value="b">

</td>
</tr>
<tr>
<td class=style5 height=25>体重:
<select name=weight_up>
<option value="0" selected>选择</option>
<option
value=35>35</option>

</select>

<select
name=weight_down>
<option value="0"
selected>选择</option>
<option
value=35>35</option>
<option

<option
value=125>125</option>
</select>
公斤居住地:
<select
name=nationality
onChange=javascript:chgCountry(form1.to_city_id);>
<option value="">--请选择--</option>
<option
value="中国大陆" selected>中国大陆</option>
<option
value="香港">---香港</option>

<option value="埃及">埃及</option>
<option
value="南非">南非</option>
</select>
<select name=to_city_id>
<option value="" selected>--请选择--</option>
<option
value="北京">北京</option>
<option value="上海">上海</option>
<option value="天津">天津</option>
<option
value="重庆">重庆</option>
<option value="广东">广东</option>
<option value="广州">---广州</option>
<option
value="深圳">---深圳</option>
<option
value="珠海">---珠海</option>

</select>
<input type=image
height=29 width=93
src="images/search.gif"
value=开始搜索 border=0 name=smtSearch> </td>
</tr>
</form>
<%
function mainsql(submitok,keyname,age_up,age_down,photo2,kind,sex)'sql变量查询
dim a,sql,fstr,agekind
fstr="select username,birthday,sex,kind,grade,alltime,click,aboutus,photo_x,photo_d,photo_x_flag,photo_d_flag,regtime,refresh_time,flag from love_main order by refresh_time desc,regtime desc,grade desc"
If submitok="a" Then'按用户名搜索
a=trim(replace(keyname,"'","''"))
fstr="select username,birthday,sex,kind,grade,alltime,click,aboutus,photo_x,photo_d,photo_x_flag,photo_d_flag,regtime,refresh_time,flag from love_main where flag<>'0' and username like '%"&a&"%' order by refresh_time desc,regtime desc,grade desc"
Elseif submitok="b" Then
fstr="select username,birthday,sex,kind,grade,alltime,click,aboutus,photo_x,photo_d,photo_x_flag,photo_d_flag,regtime,refresh_time,flag,height_ from love_main where flag<>'0'"

'性别

fstr=fstr & "and sex='"&sex&"'"

'年龄
dim a18,a19
age_up=Clng("0"&Request("age_up"))
age_down=Clng("0"&Request("age_down"))

if age_up<>0 and age_down<>0 then
if age_up>=age_down then
a18=year(now())-age_up+1
a19=year(now())-age_down+1
fstr=fstr & "and (year(birthday)>="&a18&" and year(birthday)<="&a19&")"
else
a18=year(now())-age_up+1
a19=year(now())-age_down+1
fstr=fstr & "and (year(birthday)>="&a19&" and year(birthday)<="&a18&")"
end if
else

end if

'身高范围
dim height_up,height_down,heightall
height_up=Clng("0"&Request("height_up"))
height_down=Clng("0"&Request("height_down"))

if height_up<>0 and height_down<>0 then
if height_up>=height_down then
fstr=fstr & " and height_<="& height_up&" and height_>="& height_down
else
fstr=fstr & " and height_>="& height_up&" and height_<="& height_down
end if
elseif height_up<>0 Then
fstr=fstr & " and height_>="& height_up
elseIf height_down<>0 Then
fstr=fstr & " and height_<="& height_down

end if
'有照片
if photo2="yes" then
fstr=fstr & " and (((photo_x is not null or photo_x<>'') and photo_x_flag='1') or ((photo_d is not null or photo_d<>'') and photo_d_flag='1')) "
else
fstr=fstr
end if

'体重范围
dim weight_up,weight_down
weight_up=Clng("0"&Request("weight_up"))
weight_down=Clng("0"&Request("weight_down"))
if weight_up<>0 and weight_down<>0 then
if weight_up>=weight_down then
fstr=fstr & " and weight_<="& weight_up & " and weight_>="& weight_down
else
fstr=fstr & " and weight_>="& weight_up & " and weight_<="& weight_down
end if
elseif weight_up<>0 Then
fstr=fstr & " and weight_>="&weight_up
elseIf weight_down<>0 Then
fstr=fstr & " and weight_<="&weight_down

end if
'地区
Dim nationality
to_city_id=Replace(Trim(Request("nationality")),",","''")
if nationality<>"" then fstr=fstr & "and area='"&nationality&"'"
Dim to_city_id

to_city_id=Replace(Trim(Request("to_city_id")),",","''")
if to_city_id<>"" then fstr=fstr & "and area='"& to_city_id &"'"

'总和
fstr=fstr & " order by refresh_time desc,regtime desc,grade desc"

End if
mainsql=fstr
end function
%>
里面列表可以改过文字输入.
这样就可以查出来了.哎.累死了.