永发信息网

网页表格数据横纵向显示问题请教

答案:1  悬赏:80  手机版
解决时间 2021-08-12 12:19
  • 提问者网友:鐵馬踏冰河
  • 2021-08-11 21:30

我在新闻页面中做了个新闻标题的显示表格,数据库有多少都是挤在一行里边,想让他在一行显示5个标题然后转到第二行,现在显示的结果是:

理想的效果是:

现在的表格代码是:

<table width="710" height="99" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td height="220" align="center" valign="top"><%
   TypeNumber=Trim(Replace(Request("TypeNumber"),"","'"))
   if TypeNumber="" then
   sql="select * from news where typeNumber='00040001' order by id desc"
   else
   sql="select * from news where TypeNumber='"&TypeNumber&"' order by id desc"
   end if
   rs.Open Sql,conn,1,1
            if rs.recordcount=0 then
     %>
              <table width="200" border="0" cellspacing="0" cellpadding="5" align="center">
                <tr>
                  <td id="hei" align="center">ÔÝÎÞÐÅÏ¢</td>
                </tr>
              </table>
              <%
     else
     Run=Rs.RecordCount
              %>
           <table width="720"   border="0" cellpadding="0" cellspacing="0">
                <tr>
     <%
    
                    rs.pagesize=18
                        rs.absolutepage=1
         if request.QueryString("page")<>"" then rs.absolutepage=trim(request.QueryString("page"))
            dim rowcount
               rowcount=rs.pagesize
               j=1
      k=1  
      
     %>
                  <td align="center" valign="top">
                      <table width="722" border="0" cellspacing="0" cellpadding="0" id="hei">
                        <tr><%do while not rs.eof and j<=rs.pagesize
     %>
                          <td width="26" height="24" align="center" valign="middle"><img src="img/29.jpg"></td>
                          <td width="166" align="left" valign="middle"><a href="newsx.asp?id=<%=rs("id")%>" target="_blank"><%=rs("title")%></a></td>
         <%
      k=k+1
                  rs.movenext
             j=j+1       
          loop
        %>
                        </tr>
                      </table>
                  
                  </td>
                </tr>
                <tr>
                  <td></td>
                </tr>
              </table>
              <br />
              <%
  
    end if
    rs.close
    %></td>
          </tr>
        </table>

最佳答案
  • 五星知识达人网友:痴妹与他
  • 2021-08-11 21:41

你试下


<table width="710" height="99" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td height="220" align="center" valign="top"><%
   TypeNumber=Trim(Replace(Request("TypeNumber"),"","'"))
   if TypeNumber="" then
   sql="select * from news where typeNumber='00040001' order by id desc"
   else
   sql="select * from news where TypeNumber='"&TypeNumber&"' order by id desc"
   end if
   rs.Open Sql,conn,1,1
    if rs.recordcount=0 then
    %>
    <table width="200" border="0" cellspacing="0" cellpadding="5" align="center">
    <tr>
    <td id="hei" align="center">ÔÝÎÞÐÅÏ¢</td>
    </tr>
    </table>
    <%
    else
    Run=Rs.RecordCount
    %>
    <table width="720"   border="0" cellpadding="0" cellspacing="0">
    <tr>
    <%
    
    rs.pagesize=18
    rs.absolutepage=1
    if request.QueryString("page")<>"" then rs.absolutepage=trim(request.QueryString("page"))
    dim rowcount
    rowcount=rs.pagesize
    j=1
    k=1 
    
    %>
    <td width="140" align="center" valign="top">
    <table width="722" border="0" cellspacing="0" cellpadding="0" id="hei">
    <tr><%do while not rs.eof and j<=rs.pagesize
    %>
    <td width="140" height="24" align="center" valign="middle"><img src="img/29.jpg"><a href="newsx.asp?id=<%=rs("id")%>" target="_blank"><%=rs("title")%></a></td>
    <%
    k=k+1
    rs.movenext
    j=j+1    
    loop
    %>
    <td align="left" valign="middle">&nbsp;</td>
    
    </tr>
    </table>
    
    </td>
    </tr>
    <tr>
    <td></td>
    </tr>
    </table>
    <br />
    <%
  
    end if
    rs.close
    %></td>
    </tr>
    </table>

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯