ASP Implementation Table 3 column 5 Line _ Application Tips

Source: Internet
Author: User
Programme I
Copy Code code as follows:
<!--#include file= "conn.asp"-->
<%
Owen1=request ("Owen1")
Owen2=request ("Owen2")
%>


<table width= "border=" 0 "cellpadding=" 0 "cellspacing=" 0 ">
<%
PAGE=CLNG (Request ("page")
Set rs=server.createobject ("ADODB. RecordSet ")
If owen1<> "" and Owen2 <> "" Then
Sql= "SELECT * from news where bigclassname= '" "&owen1&" ' and Smallclassname= ' "&owen2& ' ORDER by id DESC"
Rs. Open sql,conn,1,1
ElseIf owen1<> "" Then
Sql= "SELECT * from news where bigclassname= '" &owen1& "' ORDER BY id DESC"
Rs. Open sql,conn,1,1
End If
If rs.eof and Rs.bof then
Response. Write ("not recorded for the moment")
Else
%>

<%
Rs. Pagesize=15
If Page=0 then page=1
Pages=rs.pagecount
If page > pages then page=pages
Rs. Absolutepage=page
For J=1 to Rs. PageSize
if (j-1) mod 3=0 Then Response.Write ("<tr>")
%>
&LT;TD height= "align=" "Center" >
<div align= "center" > "width=" 130 "height=" "border=" "0"/ ><a href= "onews.asp?id=<%= RS (" id ")%>" target= "_blank" ><br>
<%= RS ("TITLE")%></a></div></td>
<%
If J MoD 3=0 then Response.Write ("</tr>")
Rs.movenext
If Rs.eof then exit for
Next
%>
<%
End If
Rs.close
Set rs=nothing
%>
</table>

Programme II,
Copy Code code as follows:
<!--#include file= "conn.asp"-->
<%
Owen1=request ("Owen1")
Owen2=request ("Owen2")
%>


<table width= "border=" 0 "cellpadding=" 0 "cellspacing=" 0 ">
<%
PAGE=CLNG (Request ("page")
Set rs=server.createobject ("ADODB. RecordSet ")
If owen1<> "" and Owen2 <> "" Then
Sql= "SELECT * from news where bigclassname= '" "&owen1&" ' and Smallclassname= ' "&owen2& ' ORDER by id DESC"
Rs. Open sql,conn,1,1
ElseIf owen1<> "" Then
Sql= "SELECT * from news where bigclassname= '" &owen1& "' ORDER BY id DESC"
Rs. Open sql,conn,1,1
End If
If rs.eof and Rs.bof then
Response. Write ("not recorded for the moment")
Else
%>

<%
Rs. Pagesize=15
If Page=0 then page=1
Pages=rs.pagecount
If page > pages then page=pages
Rs. Absolutepage=page
For J=1 to (Rs. PAGESIZE/3)
Response.Write ("<tr>")
For I=1 to 3
%>
&LT;TD height= "align=" "Center" >
<div align= "center" > "width=" 130 "height=" "border=" "0"/ ><a href= "onews.asp?id=<%= RS (" id ")%>" target= "_blank" ><br>
<%= RS ("TITLE")%></a></div></td>
<%
Rs.movenext
If Rs.eof then exit for
Next
Response.Write ("</tr>")
Next
%>
<%
End If
Rs.close
Set rs=nothing
%>
</table>

The code above has drawbacks.

That is, if it's 16, then the last line of the page is empty. Two columns page It's hard to see because if 16 of the last row shows only one column, this is less than two <td> </td>

Must be judged by total/3 remainder

if (rs.recordcount mod 3=2) Then Response.Write ("<td> </td>")
if (rs.recordcount mod 3=1) Then Response.Write ("<td> </td><td> </td>")

So the page is complete

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.