ASP implements Table 3 columns and 5 rows

Source: Internet
Author: User

Solution 1 CopyCode The Code is as follows: <! -- # Include file = "conn. asp" -->
<%
Owen1 = request ("owen1 ")
Owen2 = request ("owen2 ")
%>















<% 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 ("no records for now") 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> ")
%>
<TD Height = "24" align = "center">
<Div align = "center"> "width =" 130 "Height =" 100 "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
Next
%>
<%
End if
Rs. Close
Set rs = nothing
%>
</Table>

Solution 2,Copy codeThe Code is as follows: <! -- # Include file = "conn. asp" -->
<%
Owen1 = request ("owen1 ")
Owen2 = request ("owen2 ")
%>















<% 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 ("no records for now") 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
%>
<TD Height = "24" align = "center">
<Div align = "center"> "width =" 130 "Height =" 100 "border =" 0 "/> <a href =" onews. asp? Id = <% = RS ("ID") %> "target =" _ blank "> <br>
<% = RS ("title") %> </a> </div> </TD>
<%
Rs. movenext
If Rs. EOF then exit
Next
Response. Write ("</tr> ")
Next
%>
<%
End if
Rs. Close
Set rs = nothing
%>
</Table>

The above code has disadvantages ..

That is, if there are 16 entries, the last line of the page will empty two columns of the page, which is hard to see because if only one column is displayed in the last line of 16, two fewer <TD> </TD>

The remainder of total number/3 must be judged

If (Rs. recordcount mod 3 = 2) then response. Write ("<TD> </TD> ")
If (Rs. recordcount mod 3 = 1) Then response. Write ("<TD> </TD> ")

In this way, the page is complete.

Related Article

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.