3つの列と5行のテーブルを実装する方法は?この問題は多くの友人を困惑させたと思うので、この問題に基づいて3列と5列のASPテーブルを実装する方法を説明します。
計画1
次のようにコードコードをコピーします。<! - #include file = "conn.asp" - ><%
owen1 = request( "owen1")
owen2 = request( "owen2")
%>
<table width = "95%" border = "0" cellpadding = "0" cellpacing = "0">
<%
page = clng(request( "page"))
rs = server.createObject( "adodb.recordset")を設定します
owen1 <> ""およびowen2 <> "" thenの場合
sql = "select * from bigclassname = '"&owen1& "'&smallclassname = '"&owen2& "' order by id desc"
rs.open sql、conn、1,1
Elseif owen1 <> ""それから
sql = "select * from bigclassname = '"&owen1& "' order by id desc"
rs.open sql、conn、1,1
ifを終了します
rs.eofとrs.bofの場合
Response.Write( "まだレコードなし")
それ以外
%>
<%
rs.Pagesize = 15
page = 0の場合、page = 1
ページ= rs.pagecount
ページ>ページの場合、ページ=ページ
rs.absolutepage =ページ
j = 1からrs.pagesizeの場合
if(j-1)mod 3 = 0 then respons.write( "<tr>")
%>
<td height = "24" align = "center">
<div align = "center"> <img src = "uppic /<%= rs(" firstImagename ")%>" width = "130" height = "100" border = "0" /> <a href = "onews.asp?id = <%= rs(" id ")%>"ターゲット= "
<%= rs( "title")%> </a> </div> </td>
<%
J mod 3 = 0の場合、respons.write( "</tr>")
rs.movenext
rs.eofの場合は、entを終了します
次
%>
<%
ifを終了します
rs.close
rs = Nothingを設定します
%>
</table>
計画II。
コードコピーは次のとおりです。 <! - #include file = "conn.asp" - ><%
owen1 = request( "owen1")
owen2 = request( "owen2")
%>
<table width = "95%" border = "0" cellpadding = "0" cellpacing = "0">
<%
page = clng(request( "page"))
rs = server.createObject( "adodb.recordset")を設定します
owen1 <> ""およびowen2 <> "" thenの場合
sql = "select * from bigclassname = '"&owen1& "'&smallclassname = '"&owen2& "' order by id desc"
rs.open sql、conn、1,1
Elseif owen1 <> ""それから
sql = "select * from bigclassname = '"&owen1& "' order by id desc"
rs.open sql、conn、1,1
ifを終了します
rs.eofとrs.bofの場合
Response.Write( "まだレコードなし")
それ以外
%>
<%
rs.Pagesize = 15
page = 0の場合、page = 1
ページ= rs.pagecount
ページ>ページの場合、ページ=ページ
rs.absolutepage =ページ
J = 1から(rs.Pagesize/3)の場合
respons.write( "<tr>")
i = 1〜3の場合
%>
<td height = "24" align = "center">
<div align = "center"> <img src = "uppic /<%= rs(" firstImagename ")%>" width = "130" height = "100" border = "0" /> <a href = "onews.asp?id = <%= rs(" id ")%>"ターゲット= "
<%= rs( "title")%> </a> </div> </td>
<%
rs.movenext
rs.eofの場合は、entを終了します
次
respons.write( "</tr>")
次
%>
<%
ifを終了します
rs.close
rs = Nothingを設定します
%>
</table>
上記のコードには欠点があります。 。
16個のアイテムがある場合、ページの最後の行が空になり、2列が空になります。 16の最後の行に1つの列のみが表示される場合、2つの少ない<td> </td>があるため、ページは醜いです。
残りの数の総数は/3を判断する必要があります
if(rs.RecordCount mod 3 = 2)then respons.write( "<td> </td>")
if(rs.RecordCount mod 3 = 1)then respons.write( "<td> </td> <td> </td>")
このようにして、ページは完了します
これは、3つの列と5行のテーブルを実装する方法をASPに導入するためのすべてです。あなたもとても感動していますか?ここで学びたい場合は、迅速に行動を起こしてください。