方案一
復(fù)制代碼 代碼如下:
!--#include file="conn.asp"-->
%
owen1=request("owen1")
owen2=request("owen2")
%>
table width="95%" 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("暫時(shí)沒有記錄")
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">img src="uppic/%= RS("firstImageName") %>"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 for
next
%>
%
end if
rs.close
set rs=nothing
%>
/table>
方案二、
復(fù)制代碼 代碼如下:
!--#include file="conn.asp"-->
%
owen1=request("owen1")
owen2=request("owen2")
%>
table width="95%" 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("暫時(shí)沒有記錄")
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">img src="uppic/%= RS("firstImageName") %>"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 for
next
Response.Write("/tr>")
next
%>
%
end if
rs.close
set rs=nothing
%>
/table>
上面的代碼有缺點(diǎn)..
就是如果是?。保稐l 那么頁面最后一行會(huì)空出兩列 頁面很難看 因?yàn)槿绻保丁∽詈笠恍兄伙@示一列 這樣少了兩個(gè)<td></td>
必須進(jìn)行判斷 總數(shù)/3的余數(shù)
if (rs.recordcount mod 3=2) then response.write("td>nbsp;/td>")
if (rs.recordcount mod 3=1) then response.write("td>nbsp;/td>td>nbsp;/td>")
這樣頁面才完整的