下面是我一段asp代码,主要功能是将产品从数据库中调出显示在网页.可问题是代码实现的是一个产品
显示在一行上,我想将三个产品显示在同一行上,到第四个再另起一行显示,不知道如何修改.请各位高手帮忙看看,不胜感激
<%
If Request.Form("cndok")="Go" Then Response.Redirect "Product.asp?page="&Trim(Request.Form("pp"))
Set rs=Server.CreateObject("Adodb.RecordSet")
Sql = "Select * From [Product] Where [Pass]=true Order By [UpTime] Desc"
rs.Open Sql,Conn,1,1dim MaxPerPage
MaxPerPage=3
Dim text,checkpage
text="0123456789"
Rs.PageSize=MaxPerPage
for i=1 to len(request("page"))
checkpage=instr(1,text,mid(request("page"),i,1))
if checkpage=0 then
exit for
end if
nextIf checkpage<>0 then
If NOT IsEmpty(request("page")) Then
CurrentPage=Cint(request("page"))
If CurrentPage < 1 Then CurrentPage = 1
If CurrentPage > Rs.PageCount Then CurrentPage = Rs.PageCount
Else
CurrentPage= 1
End If
If not Rs.eof Then Rs.AbsolutePage = CurrentPage end if
Else
CurrentPage=1
End if
 
Function ShowProa()
Dim showH
If rs.Eof Then
showH = showH & "没有产品!"
Else
i=0
j=0
Do While Not rs.Eof
con=rs("Content")
mm=rs("Mome")
If Len(con)>30 Then con=Left(con,30) & "..."
If Len(mm)>30 Then mm=Left(mm,30) & "..."
showH = showH & "<table width=100% border=0 align=center cellpadding=5 cellspacing=1 bgcolor=#d8d8d8>"
showH = showH & "<tr><td width=25% bgcolor=#FFFFFF> <div align=left>" 
showH = showH & "<a href=ShowProduct.asp?id="&rs("ID")&"><img src=admin/"&rs("Image")&" border=0 width=100 height=80></a></div><br>"
showH = showH & " 产品名称:<a href=ShowProduct.asp?id="&rs("ID")&">"&rs("Name")&"</a><br>" 
showH = showH & "<div align=left><a href=javascript:shop("&rs("Product_ID")&");><img src=JaOne/Buy.gif border=0></a></div></td>"
showH = showH & "</tr></table>"
i=i+1 
If i >= MaxPerpage Then Exit do 
rs.MoveNext
Loop
End if
ShowProa=showH
End Function

解决方案 »

  1.   

    可以使用DataList控件实现 RepeatColumns = "3"即可
      

  2.   

    代码参见
    http://chs.gotdotnet.com/quickstart/aspplus/samples/webforms/ctrlref/webctrl/datalist/doc_datalist.aspx
      

  3.   

    发错地方了,鉴定完毕
    ---
    在循环里面弄个计数器i
    if i mod 3 = 0
    <tr>
    </tr>
    else
    <td>
    </td>
      

  4.   

    好久没用asp了,在vbscript里面取余应该是mod吧。呵呵
      

  5.   

    将ASP纪录集输出成n列的的表格形式显示的方法
    http://ms.mblogger.cn/net_lover/posts/8089.aspx
      

  6.   

    net_lover你的博客我看了,但有些还看不懂,能不能帮我解释一下.
        1.jj,nLeft,cCol 三个变量定义的是什么?
        2.Response.Write 后面的语句具体我要怎么实现
    谢谢
      

  7.   

    晕哦,是ASP问题!发这里来了。模3一换行即可
      

  8.   

    ASP应该比较好控制的吧,只要在里面设置一下值为0,再读一打记录,就加1,到能被3整除时,就换行显示