ASP查询分列显示问题

wsmhzyaba 2008-03-31 10:04:34
 <table border="1" width="80%">
<%
dim rsname,i
i=0
rsname=request("name")
rsname=Trim(request("name"))
set rs=server.CreateObject("adodb.recordset") '(建立recordset对象)
sqlstr="select * from pinmu where GOODSITEMNAME like'%"&rsname&"%' order by id desc"
'---->(message为数据库中的一个数据表即你要显示的数据所存放的数据表)
rs.open sqlstr,conn,1,3 '---->(表示打开数据库的方式)
rs.movefirst '---->(将指针移到第一条记录)
while not rs.eof '---->(判断指针是否到末尾)
%>

<%if i Mod 2 = 0 then%>
<tr><td>
<a href="javascript:()">
<%
response.write(rs("GOODSITEMNAME")) '---->(显示数据表message中的name字段)
%>
</a>
</td>
<%else%>
<td>
<a href="javascript:()">
<%
response.write(rs("GOODSITEMNAME")) '---->(显示数据表message中的name字段)
%>
</a>
</td></tr>
<%
end if
i=i+1
%>
<%
rs.movenext ' ---->(将指针移动到下一条记录)
wend %>
</table>
<% ' ---->(循环结束)
'------------------------------------------------------
rs.close
conn.close '这几句是用来关闭数据库
set rs=nothing
set conn=nothing
'
-------------------------------------------------------
%>
...全文
114 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
Lancker 2008-03-31
  • 打赏
  • 举报
回复
晕,不给分就当没有看到哈

只好瞎扯几句

循环4×4

4 4 4 4
4 4 4 4
4 4 4 4
4 4 4 4

输出4的时候使用
if not rs.eof then
4
else
0
end if

4表示你要从数据库中输出的数据
0表示占用的位置

就这样子了哈
braveboy 2008-03-31
  • 打赏
  • 举报
回复
    while not rs.eof '---->(判断指针是否到末尾) %> 
<%if i Mod 4 = 0 then response.write "<tr>"%>
................
<%if i mod 4 = 3 then response.write "</tr>"'
wend
%>

上面的写错了,-_-!!
braveboy 2008-03-31
  • 打赏
  • 举报
回复
while not rs.eof                  '---->(判断指针是否到末尾) 
%>

<%if i Mod 4 = 0 then%>
................
<%if i mod 3 = 0 then response.write "</tr>"'
wend
%>
wsmhzyaba 2008-03-31
  • 打赏
  • 举报
回复
分4列显示
itzhiren 2008-03-31
  • 打赏
  • 举报
回复
问题呢?

28,409

社区成员

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

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