欢迎光临
我们一直在努力

分栏显示记录集的表格演示,并实现了分页-ASP教程,数据库相关

建站超值云服务器,限时71元/月

<!– 本示例演示一个通用的记录集分栏显示,因为有的时候显示产品等要每行显示若干个,而不是每行显示一个。如有有这种分栏显示的表格,直接把下面的代码套进去就行了,本示例是每行显示2个记录,再最下面还显示了分页栏。 –>

<%

打开数据库

set conn = server.createobject("adodb.connection")

strconn="driver={sql server};server=localhost;database=northwind;uid=sa;pwd=sa;"

conn.open strconn

获取本页地址

dim filename,postion

filename = request.servervariables("script_name")

postion = instrrev(filename,"/")+1

filename = mid(filename,postion)

打开记录集

set rs=server.createobject("adodb.recordset")

rs.open "select titleofcourtesy,firstname,photopath from employees order by employeeid desc",conn,1,1

%>

<!– 产品展示表格 –>

<table width="90%" height="300" border="0" align="center">

<%

if not(rs.bof and rs.eof) then

pages=4

rs.pagesize=pages

if not isempty(request.querystring("page")) then

thispage=clng(request.querystring("page"))

else

thispage=1

end if

rscount=rs.recordcount

if thispage="" then thispage=1

if thispage<1 then thispage=1

if (thispage-1)*pages>rscount then

if (rscount mod pages)=0 then

thispage=rscount\pages

else

thispage=rscount\pages+1

end if

end if

if(rscount mod pages)=0 then

allpages=rscount\pages

else

allpages=rscount\pages+1

end if

rs.absolutepage=thispage

i=1

%>

<tr>

<%do while not rs.eof and pages>0 %>

<td valign="top"><a href="<%=rs("photopath")%>" target="_blank"><img src="<%=rs("photopath")%>" alt="" width="100" height="100" border="0"></a><br>

<%=rs("titleofcourtesy")&rs("firstname")%> </td>

<%

分栏主要由下面这个判断来执行的,本例是每行显示两栏

if (i mod 2) =0 then

%>

</tr><tr>

<%end if%>

<%

pages = pages – 1

rs.movenext

i=i+1

loop

end if

%>

</table>

<!– /产品展示表格 –>

<!– 产品分页表格 –>

<table width="90%" border="0" align="center">

<tr>

<td> <center>

共<%=allpages%>页&nbsp;当前第<%= thispage %>页&nbsp;

<% if thispage<>1 then %>

<a href="<%=filename&"?page=1"%>">首页</a> <a href="<%=filename&"?page="&(thispage-1)%>">上页</a>

<% end if %>

<% if thispage<>allpages then %>

<a href="<%=filename&"?page="&(thispage+1)%>">下页</a> <a href="<%=filename&"?page="&allpages&""%>">末页</a>

<% end if %>

</center></td>

</tr>

</table>

<!– /产品分页表格 –>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 分栏显示记录集的表格演示,并实现了分页-ASP教程,数据库相关
分享到: 更多 (0)

相关推荐

  • 暂无文章