asp+access下拉列表+输入框 分类查询

来源:百度知道 编辑:UC知道 时间:2024/06/20 12:19:42
<!--#include file="conn.asp"-->

<html>
<body>

<form action="chaxun.asp" method="get">
<select name="te2"><option value="1">按学号查询</option><option value="2">按姓名查询</option><option value="3">按英语水平查询</option><option value="4">按毕业年份查询</option></select>请输入您要查询的信息:<input type="text" name="te1"/><br /><input type="submit" value="查询">
</form>

<%
qyxh=""
qyxm=""
rzsj=""
gzqk=""

if request("te2") = "1" then
xh = cstr(request("te1"))
sqlstr = "select * from student where xh='" & cstr(request("te1")) & "'"
set rsx=server.createobject("adodb.recordset")
if requ

你有个 if ,要跟个 end if 表示该判断执行内容结束。。

if request("te2") = "1" then
xh = cstr(request("te1"))
sqlstr = "select * from student where xh='" & cstr(request("te1")) & "'"
end if
if request("te2") = "2" then
xm = cstr(request("te1"))
sqlstr = "select * from student where xm='" & cstr(request("te1")) & "'"
end if
set rsx=server.createobject("adodb.recordset")

=========================
以上也可以用 select case 来处理

act = request("te2")
value = cstr(request("te1"))
select case value
case "1"
sqlstr = "select * from student where xh='" & value & "'"
case "2"
sqlstr = "select * from student where xm='" & value & "'"
end select
set r