| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1926 人关注过本帖
标题:发布一个东西,大家帮着完善一下!
取消只看楼主 加入收藏
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
 问题点数:0 回复次数:17 
发布一个东西,大家帮着完善一下!
说明: tname 是要显示的名称,用"|"分隔 如: "标题|发表时间" ttype 是数据库的字段,用"|"分隔,如"title|posttime", 如果调出的字段需要链接,如title,字段所要的链接是look.asp?id=4, 则"title$look.asp?id=|posttime" table 是数据库的表名,如:"bbs" usl  是当前页面的路径,如调用面是index.asp,而url为:"index.asp?" action 是弹出页的路径,如"add.asp" width 是弹出页的宽度,如“400” height 是弹出页的高度,如"300" sessionname 是管理员登录所设的session,如session("admin") sessionpx 是帐号级别,必须是数字 使用:<% page=request.querystring("page") '分页会用到page,如果没有这句就报错! if page="" then page=1 tname="帐号|QQ|电子邮件|主页|积分|登录次数|注册时间" ttype="uname$user.asp?username=|qq|email$mailt|url$|jf|dl|atime" call showrd(tname,ttype,"user","?action="&action&"&","reg.asp","500","400",session("qx"),2) %> 函数: <% '通用记录显示函数 '作者 无根泉 '最后更新2005-6-7 '功能:支持access,ms sql server,数据库, '自定义显示数据表的记录,自定义链接字段、格式,分页显示记录,管理权限识别, '自定义文字说明,字段显示...... sub showrd(tname,ttype,table,url,action,width,height,sessionname,sessionqx) if width="" then width="400" if height="" then height="300" set rs=server.CreateObject("adodb.recordset") sql="select * from "&table&"" rs.pagesize=20 rs.open sql,conn,3,2 if rs.eof then %> <table width="740" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="30"><center> 当前没有数据![<a href="#" onClick="open('<%= action %>?action=add','','width=<%=width %>,height=<%= height %>')">添加版块</a>] </center></td> </tr> </table> <% else ipage=0 if rs.pagecount<page then page=rs.pagecount rs.absolutepage=page %> <table width="740" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#888888" style="border-left:0px; "> <tr bgcolor="#BDCBDE"> <td width="5%" height="30"><center> <strong>编号</strong> </center></td> <% tn=split(tname,"|") for tn1=0 to ubound(tn) %> <td width="477"><center> <strong><%= tn(tn1) %></strong> </center></td> <% next %> <% If sessionname<>"" or isempty(sessionname)=false Then if sessionname>sessionqx then%> <td width="15%"><center> <strong>操作</strong> </center></td> <% end if end if %> </tr> <% do while not rs.eof and ipage<rs.pagesize if page=1 then bh=(ipage+1) else bh=(page-1)*rs.pagesize+(ipage+1) end if %> <tr bgcolor="#BDCBDE"> <td height="26">&nbsp;&nbsp;<%=bh %></td> <% tty=split(ttype,"|") for tt1=0 to ubound(tty) tnm=tty(tt1)%> <td><% if instr(tnm,"$")=0 then response.Write rs(tnm) else u1=split(tnm,"$") if instr(u1(1),"id=")<>0 then response.Write "<a href="&u1(1)&rs(0)&" target='_blank'>"&rs(u1(0))&"</a>" else response.Write "<a href="&u1(1)&rs(u1(0))&" target='_blank'>"&rs(u1(0))&"</a>" end if end if%>&nbsp;&nbsp;</td> <% next %> <% If sessionname<>"" or isempty(sessionname)=false Then if sessionname>sessionqx then%> <td><center> [<a href="#" onClick="open('<%= action %>?action=add','','width=<%=width %>,height=<%=height %>')">添加</a>][<a href="#" onClick="open('<%= action %>?action=edit&id=<%= rs(0) %>','','width=<%=width %>,height=<%=height %>')">修改</a>][<a href="#" onClick="open('<%= action %>?action=del&id=<%= rs(0) %>','','width=200,height=10')">删除</a>] </center></td> <% end if end if %> </tr> <% ipage=ipage+1 rs.movenext loop %> <tr bgcolor="#BDCBDE"> <td height="24" colspan="<%=tt1+3 %>">&nbsp;<% call showpage(rs.recordcount,rs.pagesize,page,url)%></td> </tr> <% end if rs.close set rs=nothing%> </table> <% end sub %>

[此贴子已经被作者于2005-6-8 13:24:06编辑过]

搜索更多相关主题的帖子: action 管理员 color 
2005-06-06 08:51
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
自己顶一下

我很菜,但我很努力!
2005-06-06 09:39
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
说明:   本函数集显示数据记录、分页、添加、修改、删除于一身, 用法很简单,只要你像这样设定显示的文本,数据库的字段, 就可以免去写代码之苦 <% page=request.querystring("page") '分页会用到page,如果没有这句就报错! if page="" then page=1 tname="帐号|QQ|电子邮件|主页|积分|登录次数|注册时间" '表格显示的标题 ttype="uname$user.asp?username=|qq|email$mailt|url$|jf|dl|atime" '数据库中的字段 call showrd(tname,ttype,"user","?action="&action&"&","reg.asp","500","400",session("qx"),2) %> 欢迎测试!

[此贴子已经被作者于2005-6-6 14:54:55编辑过]


我很菜,但我很努力!
2005-06-06 13:35
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 

我很菜,但我很努力!
2005-06-07 15:10
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
不是吧,
本函数的功能,
显示指定数据库中的指定字段
还是来二张图吧

我很菜,但我很努力!
2005-06-07 21:24
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
运行效果:
图片附件: 游客没有浏览图片的权限,请 登录注册


图片附件: 游客没有浏览图片的权限,请 登录注册

我很菜,但我很努力!
2005-06-07 21:31
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
本人又在上面基础上加了单字段显示,按指定字段排序,链连指定字段的功能,
修改后的函数如下:
&lt;%
'通用记录显示函数
'作者 无根泉
'最后更新2005-6-7
'功能:支持access,ms sql server,数据库,
'自定义显示数据表的记录,自定义链接字段、格式,分页显示记录,管理权限识别,
'自定义文字说明,字段显示......
sub showrd(tname,ttype,table,url,action,width,height,sessionname,sessionqx,id)
if width="" then width="400"
if height="" then height="300"
set rs=server.CreateObject("adodb.recordset")
sql="select * from "&amp;table&amp;" order by "&amp;id&amp;" desc"
rs.pagesize=20
rs.open sql,conn,3,2
if rs.eof then
%&gt;
&lt;table width="740" border="0" align="center" cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
  &lt;td height="30"&gt;&lt;center&gt;
   当前没有数据![&lt;a href="#" onClick="open('&lt;%= action %&gt;?action=add','','width=&lt;%=width %&gt;,height=&lt;%= height %&gt;')"&gt;添加版块&lt;/a&gt;]
  &lt;/center&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;% else
ipage=0
if rs.pagecount&lt;page then page=rs.pagecount
rs.absolutepage=page
%&gt;
&lt;table width="740" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#555555" style="border-left:0px; "&gt;
&lt;tr bgcolor="#BDCBDE"&gt;
  &lt;td width="5%" height="30"&gt;&lt;center&gt;
   &lt;strong&gt;编号&lt;/strong&gt;
  &lt;/center&gt;&lt;/td&gt;
     &lt;%
  if instr(tname,"|")=0 then
  %&gt;&lt;td width="477"&gt;&lt;center&gt;
  &lt;strong&gt;&lt;%= tname %&gt;&lt;/strong&gt;
     &lt;/center&gt;&lt;/td&gt;
  &lt;%
  else
  tn=split(tname,"|")
  for tn1=0 to ubound(tn) %&gt;
  &lt;td width="477"&gt;&lt;center&gt;
  &lt;strong&gt;&lt;%= tn(tn1) %&gt;&lt;/strong&gt;
     &lt;/center&gt;&lt;/td&gt;
  &lt;% next
   end if%&gt;
     &lt;% If sessionname&lt;&gt;"" or isempty(sessionname)=false Then
   if sessionname&gt;sessionqx then%&gt;
  &lt;td width="15%"&gt;&lt;center&gt;
      &lt;strong&gt;操作&lt;/strong&gt;
     &lt;/center&gt;&lt;/td&gt;
  &lt;% end if
  end if %&gt;
    &lt;/tr&gt;
&lt;% do while not rs.eof and ipage&lt;rs.pagesize
if page=1 then
bh=(ipage+1)
else
bh=(page-1)*rs.pagesize+(ipage+1)
end if
if bh mod 2=0 then
color="#DEE3ED"
else
color="#eeeeee"
end if
%&gt;
&lt;tr bgcolor="&lt;%=color%&gt;"&gt;
  &lt;td height="26"&gt;&amp;nbsp;&amp;nbsp;&lt;%=bh %&gt;&lt;/td&gt;
  &lt;%
  if instr(ttype,"|")&lt;&gt;0 then
  tty=split(ttype,"|")
  for tt1=0 to ubound(tty)
   tnm=tty(tt1)%&gt;
     &lt;td&gt;&lt;%
  if instr(tnm,"$")=0 then
  response.Write rs(tnm)
  else
   u1=split(tnm,"$")
   'if instr(u1(1),"id")&lt;&gt;0 then
   response.Write "&lt;a href="&amp;u1(1)&amp;rs(id)&amp;" target='_blank'&gt;"&amp;rs(u1(0))&amp;"&lt;/a&gt;"
   'else
   'response.Write "&lt;a href="&amp;u1(1)&amp;rs(u1(0))&amp;" target='_blank'&gt;"&amp;rs(u1(0))&amp;"&lt;/a&gt;"
   'end if
     end if%&gt;&amp;nbsp;&amp;nbsp;&lt;/td&gt;
  &lt;% next
  else
  response.Write"&lt;td&gt;"
  if instr(ttype,"$")=0 then
  response.Write rs(ttype)
  else
   u1=split(ttype,"$")
   'if instr(u1(1),"id")&lt;&gt;0 then
   response.Write "&lt;a href="&amp;u1(1)&amp;rs(id)&amp;" target='_blank'&gt;"&amp;rs(u1(0))&amp;"&lt;/a&gt;"
   'else
   'response.Write "&lt;a href="&amp;u1(1)&amp;rs(u1(0))&amp;" target='_blank'&gt;"&amp;rs(u1(0))&amp;"&lt;/a&gt;"
   'end if
     end if
  response.Write"&lt;/td&gt;"
  end if%&gt;
     &lt;% If sessionname&lt;&gt;"" or isempty(sessionname)=false Then
   if sessionname&gt;sessionqx then%&gt;
  &lt;td&gt;&lt;center&gt;
  
      [&lt;a href="#" onClick="open('&lt;%= action %&gt;?action=add','','width=&lt;%=width %&gt;,height=&lt;%=height %&gt;')"&gt;添加&lt;/a&gt;][&lt;a href="#" onClick="open('&lt;%= action %&gt;?action=edit&amp;id=&lt;%= rs(0) %&gt;','','width=&lt;%=width %&gt;,height=&lt;%=height %&gt;')"&gt;修改&lt;/a&gt;][&lt;a href="#" onClick="open('&lt;%= action %&gt;?action=del&amp;id=&lt;%= rs(0) %&gt;','','width=200,height=10')"&gt;删除&lt;/a&gt;]
     &lt;/center&gt;&lt;/td&gt;
  &lt;% end if
  end if %&gt;
    &lt;/tr&gt;
&lt;% ipage=ipage+1
rs.movenext
loop %&gt;
&lt;tr bgcolor="#BDCBDE"&gt;
  &lt;td height="24" colspan="&lt;%=tt1+3 %&gt;"&gt;&amp;nbsp;&lt;% call showpage(rs.recordcount,rs.pagesize,page,url)%&gt;&lt;/td&gt;
    &lt;/tr&gt;
&lt;% end if
rs.close
set rs=nothing%&gt;
&lt;/table&gt;
&lt;% end sub %&gt;
此函数同上次发的那个分页函数一起用,
分页函数如下:
&lt;%
function showpage(cnt,size,page,url)
cot=int(cnt/size)
ca=cnt mod size
if ca&lt;&gt;0 then
cot=cot+1
else
cot=cot
end if
if page&gt;cot then page=cot
response.Write"共"&amp;cnt&amp;"条&amp;nbsp;每页"&amp;size&amp;"条&amp;nbsp;页次:"&amp;page&amp;"/"&amp;cot&amp;"&amp;nbsp;"
if page=1 then
response.Write "[首页]&amp;nbsp;[上页]&amp;nbsp;"
else
response.Write"[&lt;a href="&amp;url&amp;"page=1&gt;首页&lt;/a&gt;]&amp;nbsp;[&lt;a href="&amp;url&amp;"page="&amp;page-1&amp;"&gt;上页&lt;/a&gt;]&amp;nbsp;"
end if
if page=cot then
response.Write "[下页]&amp;nbsp;[尾页]&amp;nbsp;"
else
response.Write"[&lt;a href="&amp;url&amp;"page="&amp;page+1&amp;"&gt;下页&lt;/a&gt;]&amp;nbsp;[&lt;a href="&amp;url&amp;"page="&amp;cot&amp;"&gt;尾页&lt;/a&gt;]&amp;nbsp;"
end if
response.Write"&lt;select name='page' onchange='sed(this.value)'&gt;"
for i=1 to cot
response.Write"&lt;option value='"&amp;i&amp;"'"
if i=page then response.Write "selected"
response.Write"&gt;"&amp;i&amp;"&lt;/option&gt;"
next
response.Write"&lt;/select&gt;"
response.Write"&lt;script&gt;"
response.Write"function sed(x){"
response.Write"window.location='"&amp;url&amp;"page='+x;"
response.Write"}&lt;/script&gt;"
end function%&gt;
你所要做的就是把这二个函数拷下来,
修改一下要显示的文字,和要检索的字段!

[此贴子已经被作者于2005-6-8 13:25:17编辑过]



我很菜,但我很努力!
2005-06-07 21:36
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
用法,上面的贴图中有的, 希望俺的努力能给你带来便捷!!!

我很菜,但我很努力!
2005-06-07 21:38
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
再发二张图,这东西比文字更有说服力!
图片附件: 游客没有浏览图片的权限,请 登录注册
图片附件: 游客没有浏览图片的权限,请 登录注册

我很菜,但我很努力!
2005-06-08 07:54
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
以下是引用hxfly在2005-6-8 8:34:23的发言: 疯了 疯了
那你不打120??? 嘿嘿,你试试好不好用!

我很菜,但我很努力!
2005-06-08 09:05
快速回复:发布一个东西,大家帮着完善一下!
数据加载中...
 
   



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

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