帮我修改一下这个ASP分页代码

王朝知道·作者佚名  2011-03-28
窄屏简体版  字體: |||超大  
 
分類: 電腦/網絡 >> 程序設計 >> 其他編程語言
 
問題描述:

我对ASP不是很懂,但是现在要修改一个商品的页面

以前它是每行显示四个商品 总共两行(8个商品)多的不显示

现在我想让它显示四行 (16个商品)多的则转入下一页

原代码如下:<META http-equiv=Content-Type content="text/html; charset=gb2312">

<% set rs=server.CreateObject("adodb.recordset")

rs.open "select top 8 id,name,pic,price1,price2,adddate,stock from product where stock >= 0 order by adddate desc",conn,1,1

if rs.eof and rs.bof then

response.write "<table CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=""100%""><tr><td align=center>对不起,请您先到后台添加商品!</td></tr></table>"

else

%>

<TABLE cellSpacing=0 cellPadding=0 width=564 align=center border=0>

<TBODY>

<TR>

<% dim j

j=0

do while not rs.eof %>

<TD width=140 border="0" align=center>

<TABLE cellSpacing=0 cellPadding=0 width="140" border=0>

<TBODY>

<tr><td height="140" width="200%" align="center" background="images/136.jpg">

<A HREF=product.asp?id=<%=rs("id")%> TARGET=_blank>

<IMG ALT=上市日期<%=trim(rs("adddate"))%> SRC=<%if trim(rs("pic"))="" then %>

images/emptybook.gif

<% else %>

<% = trim(rs("pic")) %>

<% end if%> BORDER=0 width="<% = webimg9 %>" height="<% = webimg10 %>"></A></td></tr><% if rs("stock") > 0 then %>

<% else %>

<% end if %>

</TBODY>

</TABLE></TD>

<% rs.movenext

j=j+1

if rs.eof then

exit do

end if

if j>=4 then exit do

loop %> </TR>

<%

rs.absoluteposition=5

j=5 %>

<TR>

<%

do while not rs.eof %>

<TD width=140 border="0" align=center>

<TABLE cellSpacing=0 cellPadding=0 width="140" border=0>

<TBODY>

<tr><td height="140" width="200%" align="center" background="images/136.jpg">

<A HREF=product.asp?id=<%=rs("id")%> TARGET=_blank>

<IMG ALT=上市日期<%=trim(rs("adddate"))%> SRC=<%if trim(rs("pic"))="" then %>

images/emptybook.gif

<% else %>

<% = trim(rs("pic")) %>

<% end if%> BORDER=0 width="<% = webimg9 %>" height="<% = webimg10 %>"></A></td></tr>

<% if rs("stock") > 0 then %>

<% else %>

<% end if %>

</TBODY>

</TABLE></TD>

<% rs.movenext

j=j+1

if rs.eof then

exit do

end if

if j>=9 then exit do

loop %> </TR>

<%

rs.close

set rs= nothing %>

</TBODY></TABLE>

<% end if %>

最好附上中文说明!我不是很懂! 谢谢各位了

參考答案:

....

<% dim j

j=0

do while not rs.eof %>

<TD width=140 border="0" align=center>

<TABLE cellSpacing=0 cellPadding=0 width="140" border=0>

<TBODY>

<tr><td height="140" width="200%" align="center" background="images/136.jpg">

<A HREF=product.asp?id=<%=rs("id")%> TARGET=_blank>

<IMG ALT=上市日期<%=trim(rs("adddate"))%> SRC=<%if trim(rs("pic"))="" then %>

images/emptybook.gif

<% else %>

<% = trim(rs("pic")) %>

<% end if%> BORDER=0 width="<% = webimg9 %>" height="<% = webimg10 %>"></A></td></tr><% if rs("stock") > 0 then %>

<% else %>

<% end if %>

</TBODY>

</TABLE></TD>

<% rs.movenext

j=j+1

if rs.eof then

exit do

end if

if j>=4 then exit do

loop %> </TR>

<%

rs.absoluteposition=5

j=5 %>

<TR>

<%

do while not rs.eof %>

<TD width=140 border="0" align=center>

<TABLE cellSpacing=0 cellPadding=0 width="140" border=0>

<TBODY>

<tr><td height="140" width="200%" align="center" background="images/136.jpg">

<A HREF=product.asp?id=<%=rs("id")%> TARGET=_blank>

<IMG ALT=上市日期<%=trim(rs("adddate"))%> SRC=<%if trim(rs("pic"))="" then %>

images/emptybook.gif

<% else %>

<% = trim(rs("pic")) %>

<% end if%> BORDER=0 width="<% = webimg9 %>" height="<% = webimg10 %>"></A></td></tr>

<% if rs("stock") > 0 then %>

<% else %>

<% end if %>

</TBODY>

</TABLE></TD>

<% rs.movenext

j=j+1

if rs.eof then

exit do

end if

if j>=9 then exit do

loop %> </TR>

<%

rs.absoluteposition=9

j=9 %>

<TR>

<%

do while not rs.eof %>

<TD width=140 border="0" align=center>

<TABLE cellSpacing=0 cellPadding=0 width="140" border=0>

<TBODY>

<tr><td height="140" width="200%" align="center" background="images/136.jpg">

<A HREF=product.asp?id=<%=rs("id")%> TARGET=_blank>

<IMG ALT=上市日期<%=trim(rs("adddate"))%> SRC=<%if trim(rs("pic"))="" then %>

images/emptybook.gif

<% else %>

<% = trim(rs("pic")) %>

<% end if%> BORDER=0 width="<% = webimg9 %>" height="<% = webimg10 %>"></A></td></tr>

<% if rs("stock") > 0 then %>

<% else %>

<% end if %>

</TBODY>

</TABLE></TD>

<% rs.movenext

j=j+1

if rs.eof then

exit do

end if

if j>=13 then exit do

loop %> </TR>

<%

rs.absoluteposition=13 '第四行记录从第十三条记录开始读取

j=13 %>

<TR>

<%

do while not rs.eof %>

<TD width=140 border="0" align=center>

<TABLE cellSpacing=0 cellPadding=0 width="140" border=0>

<TBODY>

<tr><td height="140" width="200%" align="center" background="images/136.jpg">

<A HREF=product.asp?id=<%=rs("id")%> TARGET=_blank>

<IMG ALT=上市日期<%=trim(rs("adddate"))%> SRC=<%if trim(rs("pic"))="" then %>

images/emptybook.gif

<% else %>

<% = trim(rs("pic")) %>

<% end if%> BORDER=0 width="<% = webimg9 %>" height="<% = webimg10 %>"></A></td></tr>

<% if rs("stock") > 0 then %>

<% else %>

<% end if %>

</TBODY>

</TABLE></TD>

<% rs.movenext

j=j+1

if rs.eof then

exit do

end if

if j>=17 then exit do '当J大于16条记录时退出循环

loop %> </TR>

<%

rs.close

set rs= nothing %>

</TBODY></TABLE>

<% end if %>

....

事实上你这种显示还可以用另外一种形式表示的

小贴士:① 若网友所发内容与教科书相悖,请以教科书为准;② 若网友所发内容与科学常识、官方权威机构相悖,请以后者为准;③ 若网友所发内容不正确或者违背公序良俗,右下举报/纠错。
 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航