| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 837 人关注过本帖
标题:[求助]想一个页面显示16条记录,等于四的时候换行,不知道错哪?
只看楼主 加入收藏
quww
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-3-23
收藏
 问题点数:0 回复次数:5 
[求助]想一个页面显示16条记录,等于四的时候换行,不知道错哪?

<table width="100%" border="0" cellspacing="0" cellpadding="0">

<%Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from news order by sortid desc"
rs.open sql,conn,1,1
if not rs.eof then
rs.PageSize =16
result_num=rs.RecordCount
maxpage=rs.PageCount
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
else
result_num=0
maxpage=0
page=0
end if
if not rs.eof then
n=0
for i=1 to rs.PageSize
if n mod 4=0 then response.write "<tr>"
%>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td width="130" height="101" align="center" valign="middle" background="images/picbg1.gif">
<%if rs("firstImageName")<>"" then%>
<a href="#" target="_blank"><img src="<%=rs("firstImageName")%>" border="0" width="120" height="101"></a>
<%else%>
暂无图片
<%end if%>
</td>
</tr>
<tr align="center">
<td><%=rs("title")%></td>
</tr>
</table></td>
<%
if n mod 4=1 then response.write "</tr>"
n=n+1
rs.MoveNext:if rs.EOF then Exit For
next
end if
%>

</table>

搜索更多相关主题的帖子: 页面 记录 
2006-11-27 11:02
quww
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-3-23
收藏
得分:0 
大虾们帮忙看看啊

欢迎到趣网博客玩玩http://www. 趣网博客致力打造个性化的博客空间。
2006-11-27 11:05
quww
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-3-23
收藏
得分:0 
本想是等于4的时候换行的,可是等于2的时候就换行了

欢迎到趣网博客玩玩http://www. 趣网博客致力打造个性化的博客空间。
2006-11-27 11:11
做人很低调
Rank: 5Rank: 5
等 级:贵宾
威 望:18
帖 子:1268
专家分:0
注 册:2006-8-2
收藏
得分:0 

<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>

<%Set rs = Server.CreateObject("ADODB.Recordset")
sql = "select * from news order by sortid desc"
rs.open sql,conn,1,1
if not rs.eof then
rs.PageSize =16
result_num=rs.RecordCount
maxpage=rs.PageCount
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
else
result_num=0
maxpage=0
page=0
end if
if not rs.eof then
n=0
for i=1 to rs.PageSize

%>

<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr align="center">
<td width="130" height="101" align="center" valign="middle" background="images/picbg1.gif">
<%if rs("firstImageName")<>"" then%>
<a href="#" target="_blank"><img src="<%=rs("firstImageName")%>" border="0" width="120" height="101"></a>
<%else%>
暂无图片
<%end if%>
</td>
</tr>
<tr align="center">
<td><%=rs("title")%></td>
</tr>
</table>
</td>

<%
n=n+1
if n mod 4=0 then response.write"</tr><tr>"
rs.MoveNext:if rs.EOF then Exit For
next
end if
%>
</tr>
</table>

你这样看看。。。


其实我很低调,只是你不知道...
2006-11-27 11:16
quww
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-3-23
收藏
得分:0 
对了,谢谢老大

欢迎到趣网博客玩玩http://www. 趣网博客致力打造个性化的博客空间。
2006-11-27 11:21
做人很低调
Rank: 5Rank: 5
等 级:贵宾
威 望:18
帖 子:1268
专家分:0
注 册:2006-8-2
收藏
得分:0 
不客气
你要注意 循环的是TD 不是TR了
当MOD 4 等于0 时输出</tr><tr>就好了..

其实我很低调,只是你不知道...
2006-11-27 11:23
快速回复:[求助]想一个页面显示16条记录,等于四的时候换行,不知道错哪?
数据加载中...
 
   



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

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