源代码如下:
<%sub zt()
sql="SELECT * FROM zt where isbest = 1 ORDER BY zt_id ASC"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
do while not rs.eof
%>
<a href=showzt.asp?zt_id=<%=rs("zt_id")%> target="_blank"><%if len(rs("zt_title"))>10 then
response.write left(rs("zt_title"),10)&".."
else
response.write rs("zt_title")
end if%></a>
<%rs.movenext
loop
if rs.eof and rs.bof then%>
<font color="#666666">目前尚未有录入!</font>
<%end if
if not rs.eof or not rs.bof then
end if
rs.close
set rs=nothing
end sub%>
问题:
这个代码是直接显示数据库里的记录.但只是一列如:
******行一
******行二
******行三
******行四
...
...
现在我想把它改成二列的模式.数据可以一直增加下去.如:
******行一 ******行二
******行三 ******行四
******行五 ...
应该如何修改以上代码?
參考答案:<%
sub zt()
sql="SELECT * FROM zt where isbest = 1 ORDER BY zt_id ASC"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "<font color='#666666'>目前尚未有录入!</font>"
end if
%>
<table border="0">
<tr>
<%
b = true
do while not rs.eof
response.write "<td><a href='showzt.asp?zt_id="+rs("zt_id")+"' target='_blank'>"
if len(rs("zt_title"))>10 then
response.write left(rs("zt_title"),10)&".."
else
response.write rs("zt_title")
end if
response.write "</a></td>"
b = not b
if b then
response.write "</tr><tr>"
end if
rs.movenext
loop
%>
</tr>
</table>
<%
rs.close
set rs=nothing
end sub
%>