请教多条件判断语名

来源:百度知道 编辑:UC知道 时间:2024/07/04 07:00:27
<%
id=request("id")
lx=request("lx")
set rst=server.CreateObject("adodb.recordset")
rst.open "select * from tbl_authors" ,conn,1,1
do while not rst.eof%>

<%if lx="3D" then%>
<!--#include file="3D.asp" -->

<%elseif lx="P3" then%>
<!--#include file="P3.asp" -->

<%else%>
<!--#include file="3DP3.asp" -->

<%end if%>
<%rst.movenext
loop
rst.close
%>

总是lx为字符型,但总是判断不了前面的条件,直接输出最后一个页面,高手帮我解决一下,谢谢~
这个页面的数据库和调用的不是同一个表,只是两个里面都有个lx字段~

请先确认lx参数的确传递到此页面了,然后检查:

1、lx是通过什么方式传递到此页面的?
如果是get方法,接收参数使用Request.QueryString("lx")
如果是post方法,接收参数使用Request.Form("lx")
2、使用Trim()去掉两端空格
lx=Trim(lx)
3、将lx转化为大写
lx=UCase(lx)

其他代码不需改动。

首先程序不是你这样写的,第一:这个if不要写在循环里,如果想实现这个功能完全可以使用自写函数和子程序。
第二:如果lx的值是一定的,可以使用select
<%
id=request("id")
lx=request("lx")
set rst=server.CreateObject("adodb.recordset")
rst.open "select * from tbl_authors" ,conn,1,1
do while not rst.eof
select case lx
case "3D"
Show3D()
case "P3"
ShowP3()
case else
end select
rst.movenext
loop
rst.close
%>