asp分页多行多列代码(DIV)

本文介绍如何使用CSS实现多列布局,并展示了利用ASP进行数据分页的方法。通过具体的代码示例,读者可以了解到如何让元素浮动以创建多列布局,以及如何用ASP处理数据库查询结果并进行分页展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
把li 的样式加上float,加入固定值的width,只要这个width加起来小于等于整个宽,他可以多列显示
<div style="width:500px">
<ul>
<%for i=0 to 10%>
<li style="width:100px;float:left"><%=i%></li>
<%next%>
</ul>
</div>



<!-- 以下是通用多列多行代码-->
<table>
<% '行循环判断 to后面是行数
for i=1 to 5
%>
<tr>
<% '列循环判断 to后面是列数
for j=1 to 2
if not rs.eof then
%>
<td>显示内空</td>
<%
rs.movenext
else
%>
<td> </td>
<%
end if
next
%>
</tr>
<%
next
%>
</table>


<!-- 以下是通用分页代码-->
<!-- #i nclude file="../conn.asp" -->     //路径按自己的设置好
<%
dim i,intPage,page,pre,last,filepath
   set rs = server.CreateObject("adodb.recordset")
    sql="select * from user order by user_ID desc"
       rs.PageSize = 20          //这里设定每页显示的记录数
       rs.CursorLocation = 3
       rs.Open sql,conn,0,2,1    //这里执行你查询SQL并获得结果记录集
       pre = true
       last = true
       page = trim(Request.QueryString("page"))
      
       if len(page) = 0 then
                   intpage = 1
                   pre = false
       else
           if cint(page) =< 1 then
                intpage = 1
                pre = false
           else
               if cint(page) >= rs.PageCount then
                   intpage = rs.PageCount
                   last = false
               else
                    intpage = cint(page)
              end if
          end if
       end if
     if not rs.eof then
          rs.AbsolutePage = intpage
     end if
%>
<!--循环开始-->
<%    
    for i=1 to rs.PageSize
      if rs.EOF or rs.BOF then exit for
   %>
       ..................
      //(以下是要循环显示的内容   )..................
       ...................
    <%  
      rs.movenext
     next
    %>
<!--循环体结束
分页部分:-->
<table width="99%" border="1" cellpadding="2" cellspacing="2" borderColorLight=#808080 borderColorDark=#ffffff>
    <tr>
      <%if rs.pagecount > 0 then%>
      <td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
      <%else%>
     <td width="41%" align="left">当前页0/0</td><%end if%>
     <td width="46%" align="right"> <a href="本页.asp?page=1">首页</a>| 
      <%if pre then%>
     <%if rs.pagecount =1 then '判断是否显示上页、下页
     Response.Write""
    else %>
      <a href="本页.asp?page=<%=intpage -1%>">上页</a>| <%end if%>
      <%if last then%>
       <a href="本页.asp?page=<%=intpage +1%>">下页</a> |
<%end if
end if%>
       <a href="本页.asp?page=<%=rs.PageCount%>">尾页</a>|转到第
       <select name="sel_page" >
       <%
        for i = 1 to rs.PageCount
        if i = intpage then%>
        <option value="本页.asp?page=<%=i%>" selected><%=i%></option>
      <%else%>
        <option value="本页.asp?page=<%=i%>"><%=i%></option>
         <%
           end if
         next
         %>
      </select>页</font> 
     </td>
     </tr>
    </table>



下面是DIV的多行多列,试试

<style>
<!--
ul            { margin:0; padding:0; float: left }
li            { list-style-type: none;}
-->
</style>
<DIV>
<% 
for i=1 to 6 '行循环判断 to后面是列数
%>
<ul>
<% 
for j=1 to 4 '列循环判断 to后面是行数
if not rs.eof then
%>
<li>
<img border="1" height="131" src="http://iamh.cn/blog/images/cc.png" width="98">
</li>
<%
rs.movenext
else
%>
</li>
<%
end if
next
%>
</ul>
<%
next
%>
</DIV>
<%end if%>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值