两学一做建议:数据库提取不同数据

来源:百度文库 编辑:杭州交通信息网 时间:2024/03/29 14:30:10
<%
sql="select top 4 * from shop_books where anclassid = (select anclassid from shop_books where bookid = "&request("id")&") order by chengjiaocount,adddate desc "
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle">  <table width="590" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<%
if rs.eof and rs.bof then
response.write "<td align=center>对不起,本栏目还没有比较适合您选购的商品!</td>"
'response.End
else
%>
<%
if not rs.eof then
i=1
do while not rs.eof%>
<td width="195" height="135" align="center" valign="top">
<div align="center"></div>
<table width="20%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center"><a href=list.asp?id=<%=rs("bookid")%> class="style1">
<%if len(trim(rs("bookname")))>7 then
response.write left(trim(rs("bookname")),7)&".."
else
response.write trim(rs("bookname"))
end if
%>
</a></div></td>
</tr>
<tr>
<td><TABLE width=90 height=90 border=0 align="center" cellPadding=2 cellSpacing=1 bgColor=#e1e1e1 onmouseover="this.style.backgroundColor='#FF6600'" onmouseout="this.style.backgroundColor=''">
<TBODY>
<TR>
<TD width=90 height=90 bgColor=#ffffff align=center>
<%if rs("bookpic")="" then
response.write "<div align=center><a href=list.asp?id="&rs("bookid")&" > <img src=images/emptybook.gif width=90 height=90 border=0></a></div>"
else%>
<a href=list.asp?id=<%=rs("bookid")%>><img src="<%=trim(rs("bookpic"))%>" width=75 height=75 border=0 align=absmiddle></a>
<%end if%>
</TD>
</TR>
</TBODY>
</TABLE></td>
</tr>
</table></td>
<%if i mod 4 = 0 then%>
</tr>
<%end if
rs.movenext
i=i+1
loop
rs.close
end if
end if
end if
%>
为什么提出来的都是一样的数据,

用for或者while语句,不要单独用loop。会出错