抢分题:BOF 或 EOF 中有一个是“真”

wingcn 2006-08-28 08:42:18
一个页面设定显示4个图片,分2行,每行显示2张。现在想加个判断数据库中有无数据,但代码写入后提示错误。现贴出代码,请各位赐教:

<%Set rs= Server.CreateObject("ADODB.Recordset")
sql="select * from db_products2 where id_user='"&id&"'"
rs.open sql,conn,1,1%>

.........

<%if rs.eof and rs.bof then
response.Write "暂无图片"
else
number=1
do while not rs.eof and number<=12%>
<table><tr>
<td>
<%if not rs.eof then%>
<img src="<%=rs("img")%>"width="110" height="110" border="0">
<%number=number+1
rs.movenext
end if%>
</td>
<td>
<%if not rs.eof then%>
<img src="<%=rs("img")%>"width="110" height="110" border="0">
<%number=number+1
rs.movenext
end if%>
</td>
</tr></table>
<%loop
end if%>
...全文
179 5 打赏 收藏 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wingcn 2006-08-31
  • 打赏
  • 举报
回复
大家的回答和我想问的不一样,不过还是散分了
jinjuduo 2006-08-28
  • 打赏
  • 举报
回复

还有
sql="select * from db_products2 where id_user='"&id&"'"
你的id为自动编号还是文本类型,如果是文本没问题,如果是自动编号,则该成
sql="select * from db_products2 where id_user="&id


图片显示的时候用2楼方法比较合理

lizhilin2008 2006-08-28
  • 打赏
  • 举报
回复
楼主,先说说提示的是什么错误啊
wansai00 2006-08-28
  • 打赏
  • 举报
回复
何必这么麻烦

if 判断一下 够数了 就换行一下


=========================================

还有个更简洁的方法, 直接把那些图片都输出来 不考虑换行的问题

然后写个css控制下 不就得了
wansai00 2006-08-28
  • 打赏
  • 举报
回复
老兄 何必这么麻烦

i=0
do while not rs.eof and i <4
i=i+1
if i mod 2 =1 then response.write "</tr><tr>"
......
.....
rs.movenext : loop

28,402

社区成员

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

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