帮我把下面的一段分类代码改成两列显示,现在是一列显示的,分类类似http://www.godele.com/这个站上的分类 <!--#include file="conn.asp"--> <!--#include file="webconfig.asp"--> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> <style type="text/css"> <!-- .style1 { color: #000000; font-size: 14px; font-weight: bold; } .style4 { color: #000000; font-size: 12px;} td{ LINE-HEIGHT: 130%; } a:link { color: #333333; text-decoration:none } a:visited { color: #333333; text-decoration: none } a:hover { color: #ff0000; text-decoration: none } --> </style> </head> <body> <table width="240" border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF"> <tr> <td > <% set rs=server.CreateObject("adodb.recordset") rs.open "select * from shop_anclass order by anclassidorder",conn,1,1 if rs.recordcount=0 then response.write "<br>目前没有商品分类" else while not rs.eof %> <table height="0" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="2"><span class="style1"><div align="left"> <a href="class.asp?lx=big&anid=<%=rs("anclassid")%>" target="_blank"><u><%=rs("anclass")%></u></a></div></span></td> </tr> </table> <table border="0" cellpadding="0" cellspacing="0"> <% set rs_s=server.CreateObject("adodb.recordset") rs_s.open "select * from shop_nclass where anclassid="&rs("anclassid")&" order by nclassidorder",conn,1,1 if rs_s.recordcount=0 then %> <tr> <td colspan="8" width="240"> <table border="0" cellpadding="2" cellspacing="2"> <tr> <td align="center" colspan="7">暂无小分类</td> </tr> <% else i=0 while not rs_s.eof %> <tr> <td width="33%"> <span class="style4"> <a href="class.asp?lx=small&anid=<%=rs("anclassid")%>&nid=<%=rs_s("nclassid")%>" target="_blank"><u><%=rs_s("nclass")%></u></a> <%rs_s.movenext if rs_s.eof then response.write " " else %> </span></td> <td width="33%"> <span class="style4"><a href="class.asp?lx=small&anid=<%=rs("anclassid")%>&nid=<%=rs_s("nclassid")%>" target="_blank"><u><%=rs_s("nclass")%></u></a> <%rs_s.movenext if rs_s.eof then response.write " " else %> </span></td> <td width="33%" height="20"> <a href="class.asp?lx=small&anid=<%=rs("anclassid")%>&nid=<%=rs_s("nclassid")%>" class="style4" target="_blank"><u><%=rs_s("nclass")%></u></a> </td> <% rs_s.movenext end if end if wend end if %> </tr> </table> <% rs_s.close set rs_s=nothing rs.movenext wend end if rs.close set rs=nothing %> </body> </html>
代码较多,我给你一个思路,你尝试自己修改一下。 代码: <% Dim rs, sql, i i = 0 '这个作为一个计数器,用来控制列 Set rs = Server.CreateObject("ADODB.Recordset") sql = "SELECT ID, Title FROM myTable;" rs.Open sql, conn, 1, 1, 1 If rs.RecordCount > 0 Then Response.Write("<table width=""100%"">") Do While Not rs.EOF If i Mod 2 = 0 Then '如果被2整除,就是第一列 Response.Write("<tr><td>...</td>") '输出行的开始 tr 和第一个单元格 td Else '否则就是第二列 Response.Write("<td>......</td></tr>") '输出第二个单元格 td 和行的结束 tr End If i = i + 1 '计数器加一 rs.MoveNext Loop If i Mod 2 = 1 Then Response.Write("<td> </td></tr>") '如果最后一行只显示了一列,则补上一个空白单元格和 tr 的结束符 Response.Write("</table>") End If %>
<!--#include file="conn.asp"--> <!--#include file="webconfig.asp"--> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无标题文档</title> <style type="text/css"> <!-- .style1 { color: #000000; font-size: 14px; font-weight: bold; } .style4 { color: #000000; font-size: 12px;} td{ LINE-HEIGHT: 130%; } a:link { color: #333333; text-decoration:none } a:visited { color: #333333; text-decoration: none } a:hover { color: #ff0000; text-decoration: none } --> </style> </head> <body> <% set rs=server.CreateObject("adodb.recordset") rs.open "select * from shop_anclass order by anclassidorder",conn,1,1 if rs.recordcount=0 then response.write "<br>目前没有商品分类" else while not rs.eof %> <table height="0" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="2"><span class="style1"><div align="left"> <a href="class.asp?lx=big&anid=<%=rs("anclassid")%>" target="_blank"><u><%=rs("anclass")%></u></a></div></span></td> </tr> </table> <table height="0" border="0" cellpadding="0" cellspacing="0"> <tr> <% set rs_s=server.CreateObject("adodb.recordset") rs_s.open "select * from shop_nclass where anclassid="&rs("anclassid")&" order by nclassidorder",conn,1,1 if rs_s.recordcount=0 then %> <td align="center" colspan="7">暂无小分类</td> <% else wm_chief_MJJ=0 while not rs_s.eof if (wm_chief_MJJ mod 3)=0 then Response.Write("</tr><tr>") end if %> <td> <a href="class.asp?lx=small&anid=<%=rs("anclassid")%>&nid=<%=rs_s("nclassid")%>" target="_blank"><u><%=rs_s("nclass")%></u></a> </td> <% wm_chief_MJJ = wm_chief_MJJ + 1 rs_s.movenext wend end if %> </tr> </table> <% rs_s.close set rs_s=nothing rs.movenext wend end if rs.close set rs=nothing %> </body> </html> 不知道是不是要这样的效果