| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 364 人关注过本帖
标题:求解:如何根据字段的值,显示出不同的内容
只看楼主 加入收藏
newkw
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-4-18
结帖率:0
收藏
已结贴  问题点数:10 回复次数:2 
求解:如何根据字段的值,显示出不同的内容
  data 里面有个字段是N_Fname   ,这个字段里 有些有值的,有些是没有值的

我想显示 所有N_Fname  字段是空的信息  大家看看下面的代码 怎么改一下!

下面代码执行是没有错误的,但显示的是全部的信息!!在哪个地方改一下,只显示所有N_Fname  字段是空的信息




<!--#include file="include/Conn.asp"-->
<!--#include file="include/char.asp" -->
<!--#include file="Include/setup.asp"-->
<!--#include file="Include/check_admin.asp"-->
<%CheckAdmin1%>

<%
dim MaxPerPage                           
dim totalPut                             
dim CurrentPage                        
dim TotalPages
dim i,j
dim idlist
dim title
dim hpath
dim hfile

MaxPerPage=back_count
title=trim(request("txtitle"))
if not isempty(request("page")) then      
currentPage=cint(request("page"))         
else
currentPage=1
end if
  if not isempty(request("selAnnounce")) then
  idlist=request("selAnnounce")
  if instr(idlist,",")>0 then
dim idarr
idArr=split(idlist)
dim id
for i = 0 to ubound(idarr)
 id=clng(idarr(i))
 call deleteannounce(id)
next
  else
call deleteannounce(clng(idlist))
  end if
  end if
dim sql
dim rs
%>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
return " 不 选 "; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return " 全 选 "; }
}
//  End -->
</script>

<link href="css/style.css" rel="stylesheet" type="text/css">
<body leftmargin="2" topmargin="8">
<table border="0" width="1075" cellspacing="0" cellpadding="0" align="center">
  <tr>
  
 <td width="100%" align="center">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <form name="searchsoft" method="POST" action="Admin_Manage.asp"><tr>
 <td>
  &nbsp;&nbsp;按产品名查找:
  <input name="txtitle" type="text" class=smallInput size="13">
  &nbsp;
  <input type="submit" value="查 询" name="title" class="buttonface">
   
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a  
href="Admin_NOhtml.asp">查看未生成HTML的库存</a></td>
  </tr> </form>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td height="30" align="center" valign="top"><a href="Admin_Manage.asp">全部产品</a></td>

  <td align="center" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>选择产品分类<select name="id" align="absmiddle" size="1" style="font-size: 9pt"  
onChange='javascript:window.open("?SortID="+this.options[this.selectedIndex].value,"_self")'>
    <option value="">选择分类</option>
            
           <%i=1
          menu(0)%>
            
          </select></td>
  </tr></table></td>
</tr>
</table>
<table width="1075" border="0" cellspacing="0" cellpadding="0">
<form method=Post action="Admin_Manage.asp"><tr>
<td>
<%sortid=Request("SortID")
if sortid<>"" then
subdir=conn.execute("select count(*) from cla where f_id="&sortid)(0)
If subdir>0 Then
Response.Write "<script>alert(""你选择的分类含有子分类,请选择最低层分
类!"");location.href=""javascript:history.back()"";</script>"
Response.end()
end if
end if
if sortid<>"" then
if session(ES_AdminACT)="input" then
sql="select * from data where cla="&sortid&" and author='"&Session(ES_Admin)&"' order by ID desc"
else
sql="select * from data where cla="&sortid&" order by ID desc"
end if

end if

if title<>"" then

if session(ES_AdminACT)="input" then
sql="select * from data where (name like '%"&title&"%' or namee like '%"&title&"%') and author='"&Session(ES_Admin)
&"' order by ID desc"
else
sql="select * from data where name like '%"&title&"%' or namee like '%"&title&"%' order by ID desc"
end if

end if
if title="" and sortid="" then

if session(ES_AdminACT)="input" then
sql="select * from data where author='"&Session(ES_Admin)&"' order by ID desc"
else
sql="select * from data order by ID desc"
end if

end if
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1

  if rs.eof and rs.bof then
 response.write "<p align='center'> 没有查询到您需要的记录 </p>"
else
totalPut=rs.recordcount
if currentpage<1 then
 currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
  currentpage= totalPut \ MaxPerPage
  else
currentpage= totalPut \ MaxPerPage + 1
end if

end if
 if currentPage=1 then
  showpage totalput,MaxPerPage,"Admin_Manage.asp"
showContent
showpage totalput,MaxPerPage,"Admin_Manage.asp"
 else
 if (currentPage-1)*MaxPerPage<totalPut then
rs.move  (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
  showpage totalput,MaxPerPage,"Admin_Manage.asp"
showContent
 showpage totalput,MaxPerPage,"Admin_Manage.asp"
  else
  currentPage=1
  showpage totalput,MaxPerPage,"Admin_Manage.asp"
  showContent
  showpage totalput,MaxPerPage,"Admin_Manage.asp"
end if
end if
rs.close
end if
  
set rs=nothing  
conn.close
set conn=nothing
  
sub showContent
 dim i
i=0
%>
              <table width="1075" border="0" align="center" cellpadding="0" cellspacing="1"  
bordercolorlight="#cccccc" bordercolordark="#FFFFFF" bgcolor="#CCCCCC">
                <tr bgcolor="#EAEAEA">
                  <td width="4%" height="22" align="center">ID</td>
                  <td width="13%" align="center">型号</td>
                  <td width="10%" align="center">品牌</td>
                  <td width="8%" align="center">封装</td>
                  <td width="3%" align="center">年份</td>
                  <td width="4%" align="center">数量</td>
                  <td width="14%" align="center">备注</td>
                  <td width="11%" align="center">发布时间</td>
                  <td colspan="13" align="center">操作</td>
                </tr>
                <%do while not rs.eof%>
                <tr bgcolor="#FFFFFF">
                  <td width="4%" height="23" align="center"><%=rs("id")%></td>
                  <td width="13%" align="center">
                    <% if len(rs("name"))>15 then%>
                    <%=left(rs("name"),15)%>...
                    <%else%>
                    <%=rs("name")%>
                    <%end if%>                  </td>
                  <td width="10%" align="center"><%=rs("ppz")%></td>
                  <td width="8%" align="center"><%=rs("fzz")%></td>
                  <td width="3%" align="center"><%=rs("nfz")%></td>
                  <td width="4%" align="center"><%=rs("slz")%></td>
                  <td width="14%" align="center"><%=rs("bzz")%></td>
                  <td width="11%" align="center"><%=rs("date")%></td>
                  <td width="3%"> <div align="center"><%if rs("N_Fname")<>"" then%>        
    <a href="../<%=rs("cpath")%>/<%=rs("N_Fname")%>" target="_blank" class="back"><font color="#00FF00">查看
</font></a>
<%else%>
<a href="Smyhtml.asp?id=<%=rs("ID")%>&cla=<%=rs("cla")%>"><font color="#FF0000">NOHtml</font></a>
<%end if%></div></td>
                  <td width="3%"><div align="center"><a href="Admin_Editpic.asp?id=<%=rs("ID")%>">修改
</a></div></td>
                  <%
                 if session(ES_AdminACT)="input" then
                 else
                  %>
                  <td width="1%"> <p align="center">
                      <input type='checkbox' name='selAnnounce' value='<%=cstr(rs("ID"))%>' style="border:0px">
                  </td>
                  <td width="7%" align="center">
<%if request("action")="tjtjjdcp" then
set rs_tj=server.createobject("adodb.recordset")
sql_tj="select * from data where id="&request("id")
rs_tj.open sql_tj,conn,1,3
rs_tj("tjjdcp")=2
rs_tj.update
rs_tj.close
set rs_tj=nothing
response.Redirect("admin_manage.asp")

end if%>


<%if request("action")="qxtjjdcp" then
set rs_tj=server.createobject("adodb.recordset")
sql_tj="select * from data where id="&request("id")
rs_tj.open sql_tj,conn,1,3
rs_tj("tjjdcp")=1
rs_tj.update
rs_tj.close
set rs_tj=nothing
response.Redirect("admin_manage.asp")
end if%>
    <%if rs("tjjdcp")=1 then%>
    <a href=admin_manage.asp?action=tjtjjdcp&id=<%=rs("id")%>>推荐显示</a>
    <%else%>
        <a href=admin_manage.asp?action=qxtjjdcp&id=<%=rs("id")%>><font color="#FF0000">取消推荐显示
</font></a>
        <%end if%>
    </td>
   
   
<td width="7%" align="center">
<%if request("action")="xsyskc" then
set rs_ys=server.createobject("adodb.recordset")
sql_ys="select * from data where id="&request("id")
rs_ys.open sql_ys,conn,1,3
rs_ys("yskc")=2
rs_ys.update
rs_ys.close
set rs_ys=nothing
response.Redirect("admin_manage.asp")

end if%>


<%if request("action")="qxxsyskc" then
set rs_ys=server.createobject("adodb.recordset")
sql_ys="select * from data where id="&request("id")
rs_ys.open sql_ys,conn,1,3
rs_ys("yskc")=1
rs_ys.update
rs_ys.close
set rs_ys=nothing
response.Redirect("admin_manage.asp")
end if%>
    <%if rs("yskc")=1 then%>
    <a href=admin_manage.asp?action=xsyskc&id=<%=rs("id")%>>显示优势</a>
    <%else%>
        <a href=admin_manage.asp?action=qxxsyskc&id=<%=rs("id")%>><font color="#FF0000">取消优势</font></a>
        <%end if%>
    </td>   
   
   
   
   
                  <td width="7%" align="center">
                  
                  

<%if request("action")="tjzypd" then
set rs_tj=server.createobject("adodb.recordset")
sql_tj="select * from data where id="&request("id")
rs_tj.open sql_tj,conn,1,3
rs_tj("tjzypd")=2
rs_tj.update
rs_tj.close
set rs_tj=nothing
response.Redirect("admin_manage.asp")
end if%>


<%if request("action")="qxtjzypd" then
set rs_tj=server.createobject("adodb.recordset")
sql_tj="select * from data where id="&request("id")
rs_tj.open sql_tj,conn,1,3
rs_tj("tjzypd")=1
rs_tj.update
rs_tj.close
set rs_tj=nothing
response.Redirect("admin_manage.asp")
end if%>
    <%if rs("tjzypd")=1 then%>
    <a href=admin_manage.asp?action=tjzypd&id=<%=rs("id")%>>滚动显示</a>
    <%else%>
        <a href=admin_manage.asp?action=qxtjzypd&id=<%=rs("id")%>><font color="#FF0000">取消滚动显示
</font></a>
        <%end if%>
                  
                  
                  </td>
                  <% end if %>
                </tr>
                <%
i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
%>
                <tr bgcolor="#EAEAEA">
                  <td colspan="20%"align="right">&nbsp;
                    <%
if session(ES_AdminACT)="input" then
else
%>
                    <input name="button" type=button onClick="this.value=check(this.form.selAnnounce)" value=" 全 选  
">
                    <input name="submit" type='submit' class=buttonface value=' 删 除 ' onClick="return confirm('Are  
you sure to delete?');">
                    <% end if %>                  </td>
                </tr>
              </table>

<%
end sub

function showpage(totalnumber,maxperpage,filename)
  dim n
  dim rs
  dim sql
  if totalnumber mod maxperpage=0 then
  n= totalnumber \ maxperpage
  else
  n= totalnumber \ maxperpage+1
  end if
  response.write "<p align='center'>&nbsp;"
  if CurrentPage<2 then
 response.write "首页 上一页&nbsp;"
  else
 response.write "<a href="&filename&"?SortID_b="&sortid_b&"&page=1>首页</a>&nbsp;"
 response.write "<a href="&filename&"?SortID_b="&sortid_b&"&page="&CurrentPage-1&">上一页</a>&nbsp;"
  end if
  if n-currentpage<1 then
 response.write "下一页 尾页"
  else
 response.write "<a href="&filename&"?SortID_b="&sortid_b&"&page="&(CurrentPage+1)&">"
 response.write "下一页</a> <a href="&filename&"?SortID_b="&sortid_b&"&page="&n&">尾页</a>"
  end if
response.write "&nbsp;页次:<strong>"&CurrentPage&"/"&n&"</strong>页"
response.write "&nbsp;共<b>"&totalnumber&"</b>个产品 <b>"&maxperpage&"</b>个产品/页"
 
end function

  sub deleteannounce(id)
   set rs=server.createobject("adodb.recordset")
 sql="select * from data where ID="&cstr(id)
 rs.open sql,conn,1,1
    hpath=rs("cpath")
    hfile=rs("N_Fname")
    if hfile<>"" then
    FiLePaTh =  server.mappath("..\"&hpath& "\" & hfile)
    Set fso = CreateObject("Scripting.FileSystemObject")
    fso.DeleteFile(filepath)
   
    Set fso = nothing
    rs.close
    set rs=nothing
   
 CheckAdmin2
 sql="delete from data where ID="&cstr(id)
 conn.execute sql
 if err.Number<>0 then
err.clear
response.write "删 除 失 败 !<br>"
 else
 Response.Write "<script>alert(""删除成功"");location.href=""Admin_Manage.asp"";</script>"
 end if
 else
  CheckAdmin2
 sql="delete from data where ID="&cstr(id)
 conn.execute sql
 if err.Number<>0 then
err.clear
response.write "删 除 失 败 !<br>"
 else
 Response.Write "<script>alert(""删除成功"");location.href=""Admin_Manage.asp"";</script>"
 end if
 end if
  End sub
%>

</td>
  </tr></form>
</table> </td>
  </tr>
</table>
<%
'列出所有节点

function menu(id)
set rss=server.CreateObject("adodb.recordset")
sqls="select * from cla where f_id="&id&" order by s_order,id"
rss.open sqls,conn,1,1
'response.write("<table border='0' cellspacing='0' cellpadding='0'>")
if i=1 then
line=""
else
line="|"
line0="-"
for t=2 to i
line=line&line0
next
end if
while not rss.eof
ChildCount=conn.execute("select count(*) from cla where f_id="&rss("id"))(0)

%>

<option value="<%=rss("id")%>"><%=line&trim(rss("cla_s"))%></option>
<%
 if ChildCount>0 then
 i=i+1
call menu(rss("id"))
end if
rss.movenext

wend
i=1
'response.write("</table>")
rss.close
set rss=nothing
end function
 %>
搜索更多相关主题的帖子: include 如何 file 信息 
2011-04-19 02:45
dzt0001
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:蒙面侠
威 望:5
帖 子:1281
专家分:4998
注 册:2005-10-12
收藏
得分:5 
楼主你的代码太多了,要看完全部代码估计大家都没这个耐心

----我怎能在别人的苦难面前转过脸去----
2011-04-19 10:09
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:5 
SQL语句一句就可以解决
select * from data where N_Fname=''
2011-04-19 11:29
快速回复:求解:如何根据字段的值,显示出不同的内容
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048366 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved