永发信息网

(asp急!!)循环以N行2列显示该怎么解决?

答案:2  悬赏:80  手机版
解决时间 2021-05-10 17:22
  • 提问者网友:ミ烙印ゝ
  • 2021-05-09 18:26

我现在的代码是这样的:

现在是这样显示的

1

2

3

4

这样的 我想让他这样显示

1 2

3 4

请高手解决下 我没有分了 希望有好人 能帮我解决下

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<!--#include file="inc/conn.asp"-->
<!--#include file="inc/function.asp"-->
<!--#include file="inc/SF_Sql.asp"-->
<!--#include file="inc/cook.asp"-->
<style type="text/css">
<!--
a {
font-size: 14px;
color: #0033FF;
}

a:link {
font-size: 12px;
color: #7F7F7F;
text-decoration: none;
}
a:hover {
font-size: 12px;
color: #FF0000;
text-decoration: underline;
}
a:active {
font-size: 12px;
color: #7F7F7F;
text-decoration: none;
}
a:visited {
font-size: 12px;
color: #7F7F7F;
text-decoration: none;
}

BODY {
FONT-SIZE: 12px; COLOR: #000000
}
.ycbt {
BACKGROUND-IMAGE: url(../img/k_bg.gif);
font-weight: bold;
color: #1B304D;
font-size: 14px;
}
.xsbt {
BACKGROUND-IMAGE: url(../img/k.gif);
font-weight: bold;
color: #1B304D;
font-size: 14px;
}
.xsnr {
DISPLAY: block
}
.ycnr {
DISPLAY: none
}
.STYLE3 {
font-size: 9pt;
color: #26345B;
}
.STYLE4 {
font-size: 12px;
font-weight: bold;
color: #666666;
}

-->
</style>
<body>


<SCRIPT type=text/javascript>
function tb_xs(t,m,n){
for(var i=1;i<=m;i++){
if (i != n){
document.getElementById("tb"+t+ "_bt" + i).className= "ycbt";
document.getElementById("tb"+t+ "_nr" + i).className= "ycnr";}
else{
document.getElementById("tb"+t+ "_bt" + i).className= "xsbt";
document.getElementById("tb"+t+ "_nr" + i).className= "xsnr";}}}
</SCRIPT>

<table width="100%" height="7" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
<TABLE width=650 border=0 align="center" cellPadding=0 cellSpacing=0>
<TBODY>
<TR align=middle>
<TD width="60" height=32 align="center" class=xsbt id=tb1_bt1 onmouseover=tb_xs(1,4,1)><a href="#"><font color="#1B304D">推荐任务</font></a></TD>
<TD width="60" align="center" class=ycbt id=tb1_bt2 onmouseover=tb_xs(1,4,2)><a href="#"><font color="#1B304D">最新任务</font></a></TD>
<TD width="550" align="right" background="img/k_bg.gif">&nbsp;</TD>

</TR>
<TR align="center">
<TD colSpan=4 valign="top" bgColor=#ffffff>

<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="137" height="25"><span class="STYLE3">悬赏金额</span></td>
<td width="300" class="STYLE3">任务</td>
</tr>
</table>
<table class=xsnr id=tb1_nr1 width="98%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="80" align="center" valign="top">










<table width="410" height="20" border="0" align="center" cellpadding="0" cellspacing="0">

<%set rs=server.createobject("adodb.recordset")
sql="select top 60 * from SMT_sca where SMT_key3=1 order by SMT_tjdate desc"
rs.open sql,conn,1,1
do while not rs.eof
%>

<tr>

<td width="110" height="20" bgcolor="#FFFFFF"><span class="STYLE4">¥</span>&nbsp;<font color="#FF6600"><strong><%=rs("smt_qian")%></strong></font></td>

<td width="300" bgcolor="#FFFFFF"><a href="sca_view.asp?id=<%=rs("SMT_id")%>" target="_blank">
<%call conleft(rs("SMT_scatitle"),29)%>
</a></td>

</tr>

<%rs.movenext
loop
rs.close%>
</table>





<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" align="right"> </td>
</tr>
</table> </td>
</tr>
</table>

<table class=ycnr id=tb1_nr2 width="98%" border="0" cellpadding="0" cellspacing="1">
<tr align="center">
<td height="80" valign="top" ><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">

<%set rs=server.createobject("adodb.recordset")
sql="select top 27 * from SMT_sca where smt_key1=1 order by SMT_begindate desc"
rs.open sql,conn,1,1
do while not rs.eof
%>
<tr>
<td width="19%" height="20" bgcolor="#FFFFFF"><span class="STYLE4">¥</span>&nbsp;<font color="#FF6600"><strong><%=rs("smt_qian")%></strong></font></td>
<td width="42%" bgcolor="#FFFFFF"><a href="sca_view.asp?id=<%=rs("SMT_id")%>" target="_blank">
<%call conleft(rs("SMT_scatitle"),29)%>
</a></td>

</tr>
<%rs.movenext
loop
rs.close%>
</table>
</td>
</tr>
</table>

</TD>
</TR>
</TBODY>
</TABLE>
</html>
</body>

最佳答案
  • 五星知识达人网友:玩世
  • 2021-05-09 19:20
加个计数器,如果i然后i=i+1当i%2=0时就添加一个<tr>
全部回答
  • 1楼网友:迟山
  • 2021-05-09 19:38

<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">

<%set rs=server.createobject("adodb.recordset") sql="select top 60 * from SMT_sca where SMT_key3=1 order by SMT_tjdate desc" rs.open sql,conn,1,1 %>

<tr> <%

i=0

do while not rs.eof

i=i+1

%> <td width="110" height="20" bgcolor="#FFFFFF"><span class="STYLE4">¥</span>&nbsp;<font color="#FF6600"><strong><%=rs("smt_qian")%></strong></font></td>

<% if i mod 2=0 then response.write("</tr><tr>")

rs.move

loop

rs.close%> </tr> </table>

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯