asp调用数据库内容后,记录横向排列

2024-12-19 21:32:58
推荐回答(4个)
回答1:





<%
dim rsSub
set rsSub=server.CreateObject("adodb.recordset")
rsSub.open "select sorts,sortsid from sorts where categoryid="&rs("categoryid")&" order by sortsorder",conn,1,1
if rsSub.recordcount=0 then response.Write "对不起!此大类没有添加小类!"
n=0
response.write("")
do while not rsSub.eof
response.write(" "
n=n+1
if (n mod 4=0) then
response.write("")
end if
rsSub.movenext
loop
rsSub.close
set rsSub=nothing
%>

<%=rs("category")%>
")
response.Write ""&trim(rsSub("sorts"))&" "
'response.write ""&trim(rsSub("sorts"))&" |


<%
rs.movenext
loop
rs.close
set rs=nothing
%>







回答2:

代码我懒的看了,劝你向DIV+CSS转变吧,TABLE代码量太大,脑子都看晕了,给你个方案:
主要看下面的CSS,
ul li{
width:198px;
float:left;
}
下面的代码和你差不多了


<%
dim rsSub
set rsSub=server.CreateObject("adodb.recordset")
rsSub.open "select sorts,sortsid from sorts where categoryid="&rs("categoryid")&" order by sortsorder",conn,1,1
if rsSub.recordcount=0 then response.Write "对不起!此大类没有添加小类!"
else
%>

回答3:

不就是四行四列.



<%
dim rsSub,s
s=1
set rsSub=server.CreateObject("adodb.recordset")
rsSub.open "select sorts,sortsid from sorts where categoryid="&rs("categoryid")&" order by sortsorder",conn,1,1
if rsSub.recordcount=0 then response.Write "对不起!此大类没有添加小类!"
do while not rsSub.eof
if s mod 5=0 then
%>
<%else%>
<%
end if
s=s+1
rs.movenext
loop
rsSub.close
set rsSub=nothing
%>





<%response.Write ""&trim(rsSub("sorts"))&""%>





<%response.Write ""&trim(rsSub("sorts"))&""%>



<%
rs.movenext
loop
rs.close
set rs=nothing
%>







回答4:

用一个表格。

i →
j ■■■■
↓■■■■

<%
dim rowc,colc,i,j

rowc = 5
colc = 4
%>


<%
for j = 1 to rowc
if rs.eof then : exit for : end if
%>

<%
for i = 1 to colc
%>

<%next%>

<%
if not rs.eof then
'在这输出内容
rs.movenext
end if
%>

<%next%>