asp调用数据库内容后,记录横向排列
<tablewidth="80"height="45"border="1"><tr><tdwidth="118"><spanclass="title"><%=rs("ca...
<table width="80" height="45" border="1">
<tr>
<td width="118"><span class="title"><%=rs("category")%></span></td>
</tr>
<tr>
<td><%
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 "对不起!此大类没有添加小类!"
do while not rsSub.eof
response.Write "<a href=sub.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</a> "
'response.write "<A href=class.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</A> | "
rsSub.movenext
loop
rsSub.close
set rsSub=nothing
%></td>
</tr>
</table></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<tr>
<td> </td>
</tr>
</table>
<br> </td>
</tr>
</table>
我想先横排四个再从第二行重新排四个```怎么改啊```只有一点点分哦```答得好,我会追加的!谢谢了
都不行
我给整篇代码吧(这放不下,请连接我的空间里面看)
http://hi.baidu.com/ruyishejifang/blog/item/17769da50cb0efff9052eebe.html 展开
<tr>
<td width="118"><span class="title"><%=rs("category")%></span></td>
</tr>
<tr>
<td><%
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 "对不起!此大类没有添加小类!"
do while not rsSub.eof
response.Write "<a href=sub.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</a> "
'response.write "<A href=class.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</A> | "
rsSub.movenext
loop
rsSub.close
set rsSub=nothing
%></td>
</tr>
</table></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<tr>
<td> </td>
</tr>
</table>
<br> </td>
</tr>
</table>
我想先横排四个再从第二行重新排四个```怎么改啊```只有一点点分哦```答得好,我会追加的!谢谢了
都不行
我给整篇代码吧(这放不下,请连接我的空间里面看)
http://hi.baidu.com/ruyishejifang/blog/item/17769da50cb0efff9052eebe.html 展开
展开全部
<table width="80" height="45" border="1">
<tr>
<td width="118"><span class="title"><%=rs("category")%></span></td>
</tr>
<%
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("<tr>")
do while not rsSub.eof
response.write("<td>")
response.Write "<a href=sub.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</a> "
'response.write "<A href=class.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</A> |</td> "
n=n+1
if (n mod 4=0) then
response.write("</tr>")
end if
rsSub.movenext
loop
rsSub.close
set rsSub=nothing
%>
</tr>
</table></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<tr>
<td> </td>
</tr>
</table>
<br> </td>
</tr>
</table>
<tr>
<td width="118"><span class="title"><%=rs("category")%></span></td>
</tr>
<%
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("<tr>")
do while not rsSub.eof
response.write("<td>")
response.Write "<a href=sub.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</a> "
'response.write "<A href=class.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</A> |</td> "
n=n+1
if (n mod 4=0) then
response.write("</tr>")
end if
rsSub.movenext
loop
rsSub.close
set rsSub=nothing
%>
</tr>
</table></td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<tr>
<td> </td>
</tr>
</table>
<br> </td>
</tr>
</table>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
代码我懒的看了,劝你向DIV+CSS转变吧,TABLE代码量太大,脑子都看晕了,给你个方案:
主要看下面的CSS,
ul li{
width:198px;
float:left;
}
下面的代码和你差不多了
<div style="width:800px;">
<%
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
%>
<ul>
<% do while not rsSub.eof%>
<li><a href=sub.asp?aid=<%=rs("categoryid")%>&nid=<%=rsSub("sortsid")><%=trim(rsSub("sorts"))%></a></li>
<% rsSub.movenext
loop
rsSub.close
set rsSub=nothing
%>
</ul>
</div>
主要看下面的CSS,
ul li{
width:198px;
float:left;
}
下面的代码和你差不多了
<div style="width:800px;">
<%
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
%>
<ul>
<% do while not rsSub.eof%>
<li><a href=sub.asp?aid=<%=rs("categoryid")%>&nid=<%=rsSub("sortsid")><%=trim(rsSub("sorts"))%></a></li>
<% rsSub.movenext
loop
rsSub.close
set rsSub=nothing
%>
</ul>
</div>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不就是四行四列.
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="xyh">
<tr>
<%
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
%><td>
<table width="200" border="0" cellpadding="0" cellspacing="0" class="xyh">
<tr>
<td align="center" valign="middle"><%response.Write "<a href=sub.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</a>"%></td>
</tr>
</table></td><tr></tr>
<%else%><td>
<table width="200" border="0" cellpadding="0" cellspacing="0" class="xyh">
<tr>
<td align="center" valign="middle"><%response.Write "<a href=sub.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</a>"%></td>
</tr>
</table></td>
<%
end if
s=s+1
rs.movenext
loop
rsSub.close
set rsSub=nothing
%>
</tr></table>
</td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<tr>
<td> </td>
</tr>
</table>
<br> </td>
</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="xyh">
<tr>
<%
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
%><td>
<table width="200" border="0" cellpadding="0" cellspacing="0" class="xyh">
<tr>
<td align="center" valign="middle"><%response.Write "<a href=sub.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</a>"%></td>
</tr>
</table></td><tr></tr>
<%else%><td>
<table width="200" border="0" cellpadding="0" cellspacing="0" class="xyh">
<tr>
<td align="center" valign="middle"><%response.Write "<a href=sub.asp?aid="&rs("categoryid")&"&nid="&rsSub("sortsid")&">"&trim(rsSub("sorts"))&"</a>"%></td>
</tr>
</table></td>
<%
end if
s=s+1
rs.movenext
loop
rsSub.close
set rsSub=nothing
%>
</tr></table>
</td>
</tr>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<tr>
<td> </td>
</tr>
</table>
<br> </td>
</tr>
</table>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用一个表格。
i →
j ■■■■
↓■■■■
<%
dim rowc,colc,i,j
rowc = 5
colc = 4
%>
<table>
<%
for j = 1 to rowc
if rs.eof then : exit for : end if
%>
<tr>
<%
for i = 1 to colc
%>
<td>
<%
if not rs.eof then
'在这输出内容
rs.movenext
end if
%>
<td>
<%next%>
</tr>
<%next%>
</table>
i →
j ■■■■
↓■■■■
<%
dim rowc,colc,i,j
rowc = 5
colc = 4
%>
<table>
<%
for j = 1 to rowc
if rs.eof then : exit for : end if
%>
<tr>
<%
for i = 1 to colc
%>
<td>
<%
if not rs.eof then
'在这输出内容
rs.movenext
end if
%>
<td>
<%next%>
</tr>
<%next%>
</table>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询