注册 登录
编程论坛 ASP技术论坛

[求助]asp关于提取数据问题

虫子世界 发布于 2009-10-29 09:44, 512 次点击
这是login.asp

<%
dim conn
set conn = Server.CreateObject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.MapPath("../data/data.mdb")
 %>
<%
if Request("username")<>"" then
    sql="select * from userhao where username='" & trim(request("username")) & "' and userpow='" & replace(trim(request("userpow")),"'","''") & "'"
    set rs = conn.Execute(sql)
    if not (rs.eof or err) then
        session("username")=rs("username")
        session("tong")=rs("tong")
        response.redirect "index.asp"
    else
%>
    <script language=Javascript>
    alert("错误!请重新输入");
    window.history.go(-1);   
    </script>
<%end if%>
<%end if%>

这是index.asp

<%         if Sort_ID<>0 then
         if session("tong") = "1" then
         strsql="select * from Product where Sort_ID<>0 order by shop_name"
         else
         strsql="select * from Product where hueiproduct=1 order by shop_name"
         end if
         else
         strsql="select * from Product where audit=1 order by shop_name"
          end if
%>

说明:tong在库中为数字0和1,我想当该用户字段中tong=1,提取sort<>0的全部字段。

要怎么改呢?


[ 本帖最后由 虫子世界 于 2009-10-29 11:34 编辑 ]
6 回复
#2
虫子世界2009-10-29 11:53
这是login.asp
 
这是login.asp文件。。
<%  
dim conn
set conn = Server.CreateObject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.MapPath("../data/data.mdb")
%>
<%
if Request("username")<>"" then
    sql="select * from userhao where username='" & trim(request("username")) & "' and userpow='" & replace(trim(request("userpow")),"'","''") & "'"
    set rs = conn.Execute(sql)
    if not (rs.eof or err) then
        session("username")=rs("username")
        session("tong")=rs("tong")  '这个是要管理员审核的,当管理审核通过后tong=1,当管理审核不通过后tong=0,当用户登陆后把tong也提取出来,后是审核通过。
        response.redirect "index.asp"
    else
%>
    <script language=Javascript>
    alert("错误!请重新输入");
    window.history.go(-1);     
    </script>
<%end if%>
<%end if%>
<%         if Sort_ID<>0 then
         if session("tong") = "1" then   '数据库中tong为0和1,当管理审核通过后运行下去。怎么搞定啊!  为什么看不到效果呢?哪位老大教教我啊!!
         strsql="select * from Product where Sort_ID<>0 order by shop_name"
#3
chenguoxing5172009-10-29 12:52
看下session("tong")里的值为多少?
#4
虫子世界2009-10-29 12:58
看下session("tong")里的值为多少?

tong在库中为数字,值为0或1


#5
chenguoxing5172009-10-29 17:55
我的意思是,执行登陆操作后,在login.asp文件中的最后,加上response.write(session("tong")),然后看里面的值为多少?
进行如下判断
 if session("tong") = "1" then   '数据库中tong为0和1,当管理审核通过后运行下去。怎么搞定啊!  为什么看不到效果呢?哪位老大教教我啊!!
就知道了
#6
虫子世界2009-10-29 18:35
session("tong")里面的值有两种情况,可以为1,也可以为0。

我想当,session("tong")里面的值为1的时候,运行下行代码。
#7
chenbofeng202009-11-01 19:06
顺序反了应该为:
if session("tong") = "1" then
strsql="select * from Product where hueiproduct=1 order by shop_name"
else
strsql="select * from Product where Sort_ID<>0 order by shop_name"
end if
        
1