日期:2014-05-17  浏览次数:20889 次

输出问题急!
查询某数据库,不管数据多少,固定输出12条记录!(如果数据不满12条也需要输出表格)

------解决方案--------------------
Response.write " <table> "
for i=1 to 12
if rs.eof then
content= " "
else
content=rs(0)
end if
response.write " <tr> <td> "&content& " </td> </tr> "
rs.movenext
next
response.write " </table> "


------解决方案--------------------
select top 12 * from YourTable order by ID asc
select top 12 * from YourTable order by ID desc

如果行数不够,可以通过输出空字符串解决

if objRs.RecordCount < 12 then
for i=1 to 12 - objRs.RecordCount
Response.Write " <tr> <td> &nbsp; </td> </tr> "
next
end if
------解决方案--------------------
<table width= "600 " border= "1 " align= "center " cellpadding= "0 " cellspacing= "0 " bordercolor= "#6666CC ">
<tr bgcolor= "#999966 ">
<td bgcolor= "#999966 "> 用户名 </td>
<td > 密码 </td>
</tr>
<%
rs.pagesize=3
rs.absolutepage=page_no
dim i
i=rs.pagesize
do while i> 0
i=i-1
if not rs.eof then
%>
<tr>
<td> <div align= "center "> <%= rs( "username ") %> </div> </td>
<td> <div align= "center "> <%=rs( "psw ") %> </div> </td>
</tr>
<%
rs.movenext
else %>
<tr>
<td> &nbsp; </td>
<td> &nbsp; </td>
</tr>
<%
end if
loop
%>
</table>