回 帖 发 新 帖 刷新版面

主题:小女子急求大家帮忙~

[em7][em7][em7]
请问各位大虾,如何把下面<table>里面的数据记录按4行和5列循环排列?? 
此问题困扰小女子多日 ,请各位GG指教~~` 

-----------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/conndata.asp" -->
<%
Dim Rechanpin
Dim Rechanpin_numRows

Set Rechanpin = Server.CreateObject("ADODB.Recordset")
Rechanpin.ActiveConnection = MM_conndata_STRING
Rechanpin.Source = "SELECT * FROM chanpin"
Rechanpin.CursorType = 0
Rechanpin.CursorLocation = 2
Rechanpin.LockType = 1
Rechanpin.Open()

Rechanpin_numRows = 0
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>产品展示</title>
</head>

<body>
<table width="376" height="148" border="1" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><table width="200" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td><%=(Rechanpin.Fields.Item("img").Value)%></td>
      </tr>
      <tr>
        <td><%=(Rechanpin.Fields.Item("name").Value)%></td>
      </tr>
      <tr>
        <td><%=(Rechanpin.Fields.Item("ID").Value)%></td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>
<%
Rechanpin.Close()
Set Rechanpin = Nothing
%>

-------------------------------------------------

请把改好的全部代码一起发上, 希望大家能帮忙~``
谢谢~

回复列表 (共3个回复)

沙发

下面是我自己写的一个函数,必要的话可以抽取为一个公共类.如果真的需要帮忙,请将源码发邮件给我可以帮你调试一下.
 public function parseDynamicArrayPicListToView1(arr,maxSize)
    dim out,i,j,currentIndex
    dim TRSize,TDSize,arrLength '行列数
    TRSize=0
    TDSize=0 
    arrLength=ubound(arr)+1 '得到数组长度 
    if arrLength < maxSize then
         TDSize=arrLength
    else
         TDSize=maxSize
    end if '确定列数
    TRSize=arrLength \ maxSize
    if cint(arrLength mod maxSize) > 0 then
         TRSize=TRSize+1
    end if '确定行数
    out="<table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"+vbcrlf
    for i=0 to TRSize-1
      out=out+"<tr>"+vbcrlf
           for j=0 to TDSize-1
                out=out+"<td width="""+cstr(100 \ TDSize)+"%"" height=190 align=center>"+vbcrlf
                currentIndex=i*TDSize+j
                if currentIndex<arrLength then
                  out=out+outPicTD1(arr(currentIndex))
                else
                  out=out+"&nbsp;"+vbcrlf
                end if
                out=out+"</td>"+vbcrlf
           next
      out=out+"</tr>"+vbcrlf
    next
    out=out+"</table>"+vbcrlf
    parseDynamicArrayPicListToView1=out
  end function

板凳

谢谢楼上的GG ``~ 可是偶看不懂~` 能否把偶发的源代码修改再贴上吗?? 谢谢了`~`

3 楼

现在很忙,不好整理,你可以发你的源码到我邮箱里,今天下午帮你解决

我来回复

您尚未登录,请登录后再回复。点此登录或注册