新人求助

auvfk7yi 2007-07-17 02:33:41
pages=rst.pagecount
if page > pages then page=pages
rst.AbsolutePage=page
bgcolor ="#FFFFFF"
for j=1 to rst.PageSize step 2
%>
<tr align="center">
<td height="30" bgcolor="<%= bgcolor %>" bordercolor="#FF0000"><%=rst("datestr")%></td>
<td height="30" bgcolor="<%= bgcolor %>" bordercolor="#FF0000"><%= rst("callerid")%></td>
<%
if not rst.eof then
rst.movenext
else
exit for
end if
%>
<td height="30" bgcolor="<%= bgcolor %>" bordercolor="#FF0000"><%=rst("datestr")%></td>
<td height="30" bgcolor="<%= bgcolor %>" bordercolor="#FF0000"><%= rst("callerid")%></td>
</tr>
<%
if not rst.eof then
rst.movenext
else
exit for
end if

if rst.eof then exit for
if bgcolor = "#FFFFFF" then
bgcolor = "#F7F8F8"
else
bgcolor = "#FFFFFF"
end if
next

这段代码是将数据库的数据分成2列刷出在一个表格中。例如,数据库中第1行数据放到表格第一列。第二行数据放到表格第二列,第三行数据放到表格第一列。这么轮流刷。上面的代码到数据为偶数时没问题。当数据是基数时就有问题。请问如何在if not rst.eof then
rst.movenext
else
exit for
end if 这个地方加入判断啊。判断下一行是否有数据。我是新人。请大家不吝赐教。谢谢了。
...全文
201 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhangjingcheng 2007-07-19
  • 打赏
  • 举报
回复
先创建一个rscL记录集
'===========================
set rsCL=server.CreateObject("adodb.recordset")
mysql = "select * from tbl_customer order by id desc"
rsCL.open mysql,conn,1,1
'=================================================
利用
while not rscl.eof
response.write rscl.fields("f1")
rscl.movenext
wend
输出所有记录。
利用下面代码替换while not rscl.eof
'===============================================
i = 1
PageNo=replace(request("PageNo"),"'","")
if not Isnumeric(PageNo) then
PageNo=1
end if
rsCL.pagesize=30 '每页多少纪录
TotalPages=rsCL.pagecount
if PageNo="" or PageNo<1 then
PageNo=1
end if
if len(PageNo)>=5 then PageNo=1
if cint(pageNo)>cint(totalpages) then
pageNo=rsCL.pagecount
end if
totalpage=rsCL.pagecount
totalrecord=rsCL.recordcount
rsCL.AbsolutePage = PageNo
RowCount=rsCL.pagesize
while not rsCL.eof and Rowcount>0
一行显示三天记录
'===================================================
for i=1 to rs.pagecount

<tr>if i mod 3=0 then<td>要显示的数据库字段</td></tr>
else
<td>要显示的数据库字段</td>
end if
rs.movnext
next

利用下面代码替换wend
'===================================================
i = i + 1
rowcount=rowcount-1
rsCL.movenext
wend
'===================================================

下面是现实上一页下一页的代码,一般放在表格下面就行了

<form name="frmPage" action="?id=1" method="post">
<table width="100%" align="center" bgcolor="#FFFFFF" class="no12">
<tr>
<td width="36%" height="23" align="center" class="black">
<%
if pageNo="" then pageno=1
if totalPages="" then TotalPages=1
if PageNo > 1 Then
response.write "<a href=?PageNo=1&id=1>首页</a> | <a href=?PageNo=" & (PageNo-1) & "&id=1>上一页</a> | "
end if
if TotalPages > 1 and cint(PageNo) <> cint(TotalPages) then
response.write "<a href=?PageNo=" & (PageNo+1) & "&id=1>下一页</a> | <a href=?PageNo=" & TotalPages & "&id=1>末页</a> "
end if
%> </td>
<td width="19%" align="left" class="black">总共<%=TotalRecord%>条记录</td>
<td width="14%" align="left"><%Response.Write "Page: 转到第"& PageNo &" / "& TotalPages &""%></td>
<td width="4%" align="left"><input name="pageNo" type="text" id="pageNo" size="4" maxlength="5" /></td>
<td width="27%" align="left"><input name="button2" type="submit" id="button2" value="GoTo" style="border:1 solid #FFFFFF" /></td>
</tr>
</table>
</form>
auvfk7yi 2007-07-19
  • 打赏
  • 举报
回复
没人帮忙吗?拜托各位帮帮忙啊。感激不尽了。
baijianlong813 2007-07-18
  • 打赏
  • 举报
回复
if not(rs.bof and eof) then
if not rst.eof then
rst.movenext
else
exit for
end if
end if
auvfk7yi 2007-07-18
  • 打赏
  • 举报
回复
按照楼上的说的也不行啊。我是要刷到一个2列的表格
也就是说每次必须取2条数据分别放到表格的第一列和第2列。
继续寻求高手帮忙。
auvfk7yi 2007-07-18
  • 打赏
  • 举报
回复
或者哪位高手做过给2列表格刷数据的代码啊。发出来给我学习学习。感激不尽。谢谢。
auvfk7yi 2007-07-18
  • 打赏
  • 举报
回复
这样也不行啊。会报错。麻烦高手帮忙啊。急啊。
huangcaihua 2007-07-17
  • 打赏
  • 举报
回复
<table>
<tr>
<%
for j=1 to rst.PageSize
if (j+1) mod 2=0 and i<>1 Then
response.write("</tr><tr>");
end if
%>
<td height="30" bgcolor="<%= bgcolor %>" bordercolor="#FF0000"><%=rst("datestr")%></td>

<%
next
%>
</tr>
</table>


这样就可以了

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧