新手求教ASP问题,请帮忙处理
本人做了的一个读取数据库内容的页面,代码如下,由于行数太多而且每行背景颜色相同很容易看串行,请高手帮加段代码使得每两行的背景颜色不同,方便查看。因为内容里加了do循环,请在内嵌入代码,麻烦提供可以使用的代码尽量不要给本人思路,因为是新手,呵呵 十分感谢!
<!-- #include file= "db.inc.asp " -->
<%
exec= "select * from kucun "
set rs=server.createobject( "adodb.recordset ")
rs.open exec,conn,1,1
%>
<div align= "center ">
<table width= "18% " border= "1 " cellpadding= "0 " cellspacing= "0 " lang= "ar ">
<td width= "10% " align= "center "> 名称 </td>
<td width= "8% " align= "center "> 数量 </td>
</tr>
<%do while not rs.eof%>
<tr>
<td> <center> <%=rs( "k_f ")%> </center> </td>
<td> <center> <%=rs( "k_k ")%> </center> </td>
</tr>
<%
rs.movenext
loop
%>
显示内容如下 希望是隔行背景颜色相同
名称 数量
苹果 100
香蕉 50
鸭梨 80
西瓜 70
...
------解决方案-------------------- <!-- #include file= "db.inc.asp " -->
<%
exec= "select * from kucun "
set rs=server.createobject( "adodb.recordset ")
rs.open exec,conn,1,1
%>
<div align= "center ">
<table width= "18% " border= "1 " cellpadding= "0 " cellspacing= "0 " lang= "ar ">
<td width= "10% " align= "center "> 名称 </td>
<td width= "8% " align= "center "> 数量 </td>
</tr>
<%dim i
i=0
do while not rs.eof
if i mod 2 =0 then
%>
<tr bgcolor= "#003399 ">
<td> <center> <%=rs( "k_f ")%> </center> </td>
<td> <center> <%=rs( "k_k ")%> </center> </td>
</tr>
<%
else
%>
<tr bgcolor= "#990000 ">
<td> <center> <%=rs( "k_f ")%> </center> </td>
<td> <center> <%=rs( "k_k ")%> </center> </td>
</tr>
<%
end if
rs.movenext
i =i +1
loop
%>