方案一
复制代码 代码如下:<>
<%
owen1=request("owen1")
owen2=request("owen2")
%>
<tablewidth="95%"border="0"cellpadding="0"cellspacing="0">
<%
page=clng(request("page"))
Setrs=Server.CreateObject("ADODB.RecordSet")
ifowen1<>""andowen2<>""then
sql="select*fromnewswhereBigClassName='"&owen1&"'andSmallClassName='"&owen2&"'orderbyiddesc"
rs.Opensql,conn,1,1
elseifowen1<>""then
sql="select*fromnewswhereBigClassName='"&owen1&"'orderbyiddesc"
rs.Opensql,conn,1,1
endif
ifrs.eofandrs.bofthen
response.Write("暂时没有记录")
else
%>
<%
rs.PageSize=15
ifpage=0thenpage=1
pages=rs.pagecount
ifpage>pagesthenpage=pages
rs.AbsolutePage=page
forj=1tors.PageSize
if(j-1)mod3=0thenResponse.Write("<tr>")
%>
<tdheight="24"align="center">
<divalign="center"><imgsrc="uppic/<%=RS("firstImageName")%>"width="130"height="100"border="0"/><ahref="onews.asp?id=<%=RS("id")%>"target="_blank"><br>
<%=RS("TITLE")%></a></div></td>
<%
ifjmod3=0thenResponse.Write("</tr>")
rs.movenext
ifrs.eofthenexitfor
next
%>
<%
endif
rs.close
setrs=nothing
%>
</table>
方案二、
复制代码 代码如下:<>
<%
owen1=request("owen1")
owen2=request("owen2")
%>
<tablewidth="95%"border="0"cellpadding="0"cellspacing="0">
<%
page=clng(request("page"))
Setrs=Server.CreateObject("ADODB.RecordSet")
ifowen1<>""andowen2<>""then
sql="select*fromnewswhereBigClassName='"&owen1&"'andSmallClassName='"&owen2&"'orderbyiddesc"
rs.Opensql,conn,1,1
elseifowen1<>""then
sql="select*fromnewswhereBigClassName='"&owen1&"'orderbyiddesc"
rs.Opensql,conn,1,1
endif
ifrs.eofandrs.bofthen
response.Write("暂时没有记录")
else
%>
<%
rs.PageSize=15
ifpage=0thenpage=1
pages=rs.pagecount
ifpage>pagesthenpage=pages
rs.AbsolutePage=page
forj=1to(rs.PageSize/3)
Response.Write("<tr>")
fori=1to3
%>
<tdheight="24"align="center">
<divalign="center"><imgsrc="uppic/<%=RS("firstImageName")%>"width="130"height="100"border="0"/><ahref="onews.asp?id=<%=RS("id")%>"target="_blank"><br>
<%=RS("TITLE")%></a></div></td>
<%
rs.movenext
ifrs.eofthenexitfor
next
Response.Write("</tr>")
next
%>
<%
endif
rs.close
setrs=nothing
%>
</table>
上面的代码有缺点..
就是如果是16条那么页面最后一行会空出两列页面很难看因为如果16最后一行只显示一列这样少了两个<td></td>
必须进行判断总数/3的余数
if(rs.recordcountmod3=2)thenresponse.write("<td></td>")
if(rs.recordcountmod3=1)thenresponse.write("<td></td><td></td>")
这样页面才完整的