| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1926 人关注过本帖
标题:发布一个东西,大家帮着完善一下!
只看楼主 加入收藏
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 
本人又在上面基础上加了单字段显示,按指定字段排序,链连指定字段的功能,
修改后的函数如下:
<%
'通用记录显示函数
'作者 无根泉
'最后更新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 "&table&" order by "&id&" desc"
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="#555555" style="border-left:0px; ">
<tr bgcolor="#BDCBDE">
  <td width="5%" height="30"><center>
   <strong>编号</strong>
  </center></td>
     <%
  if instr(tname,"|")=0 then
  %><td width="477"><center>
  <strong><%= tname %></strong>
     </center></td>
  <%
  else
  tn=split(tname,"|")
  for tn1=0 to ubound(tn) %>
  <td width="477"><center>
  <strong><%= tn(tn1) %></strong>
     </center></td>
  <% next
   end if%>
     <% 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
if bh mod 2=0 then
color="#DEE3ED"
else
color="#eeeeee"
end if
%>
<tr bgcolor="<%=color%>">
  <td height="26">  <%=bh %></td>
  <%
  if instr(ttype,"|")<>0 then
  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(id)&" 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%>  </td>
  <% next
  else
  response.Write"<td>"
  if instr(ttype,"$")=0 then
  response.Write rs(ttype)
  else
   u1=split(ttype,"$")
   'if instr(u1(1),"id")<>0 then
   response.Write "<a href="&u1(1)&rs(id)&" 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
  response.Write"</td>"
  end if%>
     <% 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 %>"> <% call showpage(rs.recordcount,rs.pagesize,page,url)%></td>
    </tr>
<% end if
rs.close
set rs=nothing%>
</table>
<% end sub %>
此函数同上次发的那个分页函数一起用,
分页函数如下:
<%
function showpage(cnt,size,page,url)
cot=int(cnt/size)
ca=cnt mod size
if ca<>0 then
cot=cot+1
else
cot=cot
end if
if page>cot then page=cot
response.Write"共"&cnt&"条 每页"&size&"条 页次:"&page&"/"&cot&" "
if page=1 then
response.Write "[首页] [上页] "
else
response.Write"[<a href="&url&"page=1>首页</a>] [<a href="&url&"page="&page-1&">上页</a>] "
end if
if page=cot then
response.Write "[下页] [尾页] "
else
response.Write"[<a href="&url&"page="&page+1&">下页</a>] [<a href="&url&"page="&cot&">尾页</a>] "
end if
response.Write"<select name='page' onchange='sed(this.value)'>"
for i=1 to cot
response.Write"<option value='"&i&"'"
if i=page then response.Write "selected"
response.Write">"&i&"</option>"
next
response.Write"</select>"
response.Write"<script>"
response.Write"function sed(x){"
response.Write"window.location='"&url&"page='+x;"
response.Write"}</script>"
end function%>
你所要做的就是把这二个函数拷下来,
修改一下要显示的文字,和要检索的字段!

[此贴子已经被作者于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
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
疯了
疯了

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

我很菜,但我很努力!
2005-06-08 09:05
suyongtao
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:33
帖 子:8674
专家分:127
注 册:2004-11-6
收藏
得分:0 
为什么加精华呀

面朝大海,春暖花开!
2005-06-08 11:03
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 

我很菜,但我很努力!
2005-06-08 13:11
hxfly
Rank: 5Rank: 5
等 级:贵宾
威 望:17
帖 子:5810
专家分:118
注 册:2005-4-7
收藏
得分:0 
以下是引用suyongtao在2005-6-8 11:03:33的发言: 为什么加精华呀
第一,我的底盘听我的 第二,我选择我喜欢 ................. 论坛的宗旨:鼓励原创!

2005-06-08 13:17
无根泉
Rank: 2
等 级:新手上路
威 望:4
帖 子:853
专家分:0
注 册:2004-11-4
收藏
得分:0 

我很菜,但我很努力!
2005-06-08 13:19
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 
明白了,跟VB中的DateGride控件差不多。
2005-06-08 14:02
快速回复:发布一个东西,大家帮着完善一下!
数据加载中...
 
   



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

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