asp图片自动排列问题 200
现在是一行一个图片,每页12个。右边显示标题和简介。如何改写代码变成一行4个图片,每页5行。图片下面为标题,不要简介了。代码如下:<tablewidth="100%"bo...
现在是一行一个图片,每页12个。右边显示标题和简介。如何改写代码变成一行4个图片,每页5行。图片下面为标题,不要简介了。代码如下:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
if mid1="" then
sql="select id,fnam,nam,cont from photos where bid="&bid&" order by tim desc"
else
sql="select id,fnam,nam,cont from photos where bid="&bid&" and mid="&mid1&" order by tim desc"
end if
rs.open sql,conn,1,1
if rs.eof then
%>
<tr>
<td height="60" align="center">暂无...</td>
</tr>
<tr>
<%
else
const ipp=12
rs.pagesize=ipp
page=checkstr(request("page"))
if page="" then
page=1
elseif cint(page)<1 then
page=1
elseif cint(page)>rs.pagecount then
page=rs.pagecount
else
page=cint(page)
end if
rs.absolutepage=page
i=0
while (not rs.eof) and i<rs.pagesize
i=i+1
img=trim(rs(1))
%>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="23%" valign="top" style="padding-top:8px;padding-bottom:8px; "><table width="134" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="border1"><a href="news/img/<%=trim(rs(1))%>" target="_blank"><img src="news/img/<%=trim(rs(1))%>" alt="<%=trim(rs(2))%>" width="130" height="123" hspace="2" vspace="2" border="0"/></a></td>
</tr>
</table>
<span class="pad1"><span class="banner_3"><%=trim(rs(2))%></span></span></td>
<td width="77%" valign="top" class="pad1"> </td>
</tr>
<tr>
<td height="3" colspan="2" align="center"></td>
</tr>
<tr>
<td height="1" colspan="2" align="center" background="images/line_hx.gif"></td>
</tr>
<tr>
<td height="5" colspan="2" align="center"></td>
</tr>
</table></td>
<%
rs.movenext
if i mod 1=0 then response.write "</td><td>"
wend
%>
</tr>
<% end if %>
</table>
上面的代码是我改了一点之后的,简介没了,但是变成全部横排了,一横排12个。关键应该是在<%
rs.movenext
if i mod 1=0 then response.write "</td><td>"
wend
%>
部分 展开
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
if mid1="" then
sql="select id,fnam,nam,cont from photos where bid="&bid&" order by tim desc"
else
sql="select id,fnam,nam,cont from photos where bid="&bid&" and mid="&mid1&" order by tim desc"
end if
rs.open sql,conn,1,1
if rs.eof then
%>
<tr>
<td height="60" align="center">暂无...</td>
</tr>
<tr>
<%
else
const ipp=12
rs.pagesize=ipp
page=checkstr(request("page"))
if page="" then
page=1
elseif cint(page)<1 then
page=1
elseif cint(page)>rs.pagecount then
page=rs.pagecount
else
page=cint(page)
end if
rs.absolutepage=page
i=0
while (not rs.eof) and i<rs.pagesize
i=i+1
img=trim(rs(1))
%>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="23%" valign="top" style="padding-top:8px;padding-bottom:8px; "><table width="134" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="border1"><a href="news/img/<%=trim(rs(1))%>" target="_blank"><img src="news/img/<%=trim(rs(1))%>" alt="<%=trim(rs(2))%>" width="130" height="123" hspace="2" vspace="2" border="0"/></a></td>
</tr>
</table>
<span class="pad1"><span class="banner_3"><%=trim(rs(2))%></span></span></td>
<td width="77%" valign="top" class="pad1"> </td>
</tr>
<tr>
<td height="3" colspan="2" align="center"></td>
</tr>
<tr>
<td height="1" colspan="2" align="center" background="images/line_hx.gif"></td>
</tr>
<tr>
<td height="5" colspan="2" align="center"></td>
</tr>
</table></td>
<%
rs.movenext
if i mod 1=0 then response.write "</td><td>"
wend
%>
</tr>
<% end if %>
</table>
上面的代码是我改了一点之后的,简介没了,但是变成全部横排了,一横排12个。关键应该是在<%
rs.movenext
if i mod 1=0 then response.write "</td><td>"
wend
%>
部分 展开
3个回答
展开全部
您好!
这样可以吗?
<table width="580" height="99" border="0" cellpadding="0" cellspacing="0">
<tr>
<%
sql="select * from cp where xx='0' order by id desc"
set M=server.createobject("adodb.recordset")
M.open sql,conn,1,1
mypage=request("whichpage")
if mypage="" then
mypage=1
else
mypage=cint(mypage)
end if
mypagesize=request("pagesize")
if mypagesize="" then
mypagesize=20
end if
M.movefirst
M.pagesize=mypagesize
maxcount=cint(M.pagecount)
M.absolutepage=mypage
how=1
y=M.pagecount
d=M.recordcount
%>
<%
a=a+1
do while not M.eof and how <=M.pagesize
%>
<td><table width="135" height="190" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#EAEAEA">
<tr>
<td height="172" bgcolor="#FDF4C1"><div align="center"><a href="productxx.asp?id=<%=M("id")%>"><img src="<%=M("pic")%>" width="112" height="145" border="0"></a></div></td>
</tr>
<tr>
<td height="16" bgcolor="#FEE39C"><div align="center"><a href="productxx.asp?id=<%=M("id")%>"><%=M("sm")%></a></div></td>
</tr>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
</table></td>
<%
if a mod 5=0 then
response.Write"<tr></tr>"
end if
M.movenext
how=how+1
a=a+1
loop
%>
</tr>
</table>
<table width="580" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><span style="font-family: "宋体"">
<%
if mypage<>1 then
response.write"<a href=product.asp> [第一页] </a>"
response.write"<a href=product.asp?whichpage="&(mypage-1)&"> [上一页] </a>"
end if
if mypage<>y then
response.write"<a href=product.asp?whichpage="&(mypage+1)&"> [下一页] </a>"
response.write"<a href=product.asp?whichpage="&y&"> [最后一页] </a>"
end if
%>
</span> 当前为<span class="STYLE2"><%=mypage%></span>页 共有<span class="STYLE2"><%=maxcount%></span>页 共有<span class="STYLE2"><%=d%></span>个产品</div></td>
</tr>
</table>
我也不是专家,有问题就发信息我,Thanks。。。
这样可以吗?
<table width="580" height="99" border="0" cellpadding="0" cellspacing="0">
<tr>
<%
sql="select * from cp where xx='0' order by id desc"
set M=server.createobject("adodb.recordset")
M.open sql,conn,1,1
mypage=request("whichpage")
if mypage="" then
mypage=1
else
mypage=cint(mypage)
end if
mypagesize=request("pagesize")
if mypagesize="" then
mypagesize=20
end if
M.movefirst
M.pagesize=mypagesize
maxcount=cint(M.pagecount)
M.absolutepage=mypage
how=1
y=M.pagecount
d=M.recordcount
%>
<%
a=a+1
do while not M.eof and how <=M.pagesize
%>
<td><table width="135" height="190" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#EAEAEA">
<tr>
<td height="172" bgcolor="#FDF4C1"><div align="center"><a href="productxx.asp?id=<%=M("id")%>"><img src="<%=M("pic")%>" width="112" height="145" border="0"></a></div></td>
</tr>
<tr>
<td height="16" bgcolor="#FEE39C"><div align="center"><a href="productxx.asp?id=<%=M("id")%>"><%=M("sm")%></a></div></td>
</tr>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
</table></td>
<%
if a mod 5=0 then
response.Write"<tr></tr>"
end if
M.movenext
how=how+1
a=a+1
loop
%>
</tr>
</table>
<table width="580" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center"><span style="font-family: "宋体"">
<%
if mypage<>1 then
response.write"<a href=product.asp> [第一页] </a>"
response.write"<a href=product.asp?whichpage="&(mypage-1)&"> [上一页] </a>"
end if
if mypage<>y then
response.write"<a href=product.asp?whichpage="&(mypage+1)&"> [下一页] </a>"
response.write"<a href=product.asp?whichpage="&y&"> [最后一页] </a>"
end if
%>
</span> 当前为<span class="STYLE2"><%=mypage%></span>页 共有<span class="STYLE2"><%=maxcount%></span>页 共有<span class="STYLE2"><%=d%></span>个产品</div></td>
</tr>
</table>
我也不是专家,有问题就发信息我,Thanks。。。
展开全部
问题出在第12行:“const ipp=12 ”这里设定了pagesize,和32行:“while (not rs.eof) and i<rs.pagesize”,这里表示循环12次,以及58行“if i mod 1=0 then response.write "</td><td>" ”,这里i mod 1=0为永真条件,因此不断输出相同的部分"</td><td>"。
请修改i mod 1=0为i mod 4=0试试看。
总之,你应该为i=0,1,2,3些不同的代码。
请修改i mod 1=0为i mod 4=0试试看。
总之,你应该为i=0,1,2,3些不同的代码。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2008-10-15
展开全部
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
if mid1="" then
sql="select id,fnam,nam,cont from photos where bid="&bid&" order by tim desc"
else
sql="select id,fnam,nam,cont from photos where bid="&bid&" and mid="&mid1&" order by tim desc"
end if
rs.open sql,conn,1,1
if rs.eof then
%>
<tr>
<td height="60" align="center">暂无...</td>
</tr>
<tr>
<%
else
const ipp=12
rs.pagesize=ipp
page=checkstr(request("page"))
if page="" then
page=1
elseif cint(page)<1 then
page=1
elseif cint(page)>rs.pagecount then
page=rs.pagecount
else
page=cint(page)
end if
rs.absolutepage=page
i=0
while (not rs.eof) and i<rs.pagesize
i=i+1
img=trim(rs(1))
%>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" style="padding-top:8px;padding-bottom:8px; "><table width="134" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="border1"><a href="news/img/<%=trim(rs(1))%>" target="_blank"><img src="news/img/<%=trim(rs(1))%>" alt="<%=trim(rs(2))%>" width="130" height="123" hspace="2" vspace="2" border="0"/></a></td>
</tr>
<tr>
<td align=center><span class="pad1"><span class="banner_3"><%=trim(rs(2))%></span></span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="3" align="center"></td>
</tr>
<tr>
<td height="1" align="center" background="images/line_hx.gif"></td>
</tr>
<tr>
<td height="5" align="center"></td>
</tr>
</table></td>
<%if i mod 4=0 then%></tr><tr><%end if%>'注意这裏,一行显示4个图片
<%
rs.movenext
wend
rs.close
set rs=nothing
%>
</tr>
<% end if %>
</table>
备注:楼主先看一下表格的效果,再控制每行显示4个.另既然准备一页显示5行的图片,为何
const ipp=12
rs.pagesize=ipp
有一点矛盾了
<%
if mid1="" then
sql="select id,fnam,nam,cont from photos where bid="&bid&" order by tim desc"
else
sql="select id,fnam,nam,cont from photos where bid="&bid&" and mid="&mid1&" order by tim desc"
end if
rs.open sql,conn,1,1
if rs.eof then
%>
<tr>
<td height="60" align="center">暂无...</td>
</tr>
<tr>
<%
else
const ipp=12
rs.pagesize=ipp
page=checkstr(request("page"))
if page="" then
page=1
elseif cint(page)<1 then
page=1
elseif cint(page)>rs.pagecount then
page=rs.pagecount
else
page=cint(page)
end if
rs.absolutepage=page
i=0
while (not rs.eof) and i<rs.pagesize
i=i+1
img=trim(rs(1))
%>
<td><table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" style="padding-top:8px;padding-bottom:8px; "><table width="134" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="border1"><a href="news/img/<%=trim(rs(1))%>" target="_blank"><img src="news/img/<%=trim(rs(1))%>" alt="<%=trim(rs(2))%>" width="130" height="123" hspace="2" vspace="2" border="0"/></a></td>
</tr>
<tr>
<td align=center><span class="pad1"><span class="banner_3"><%=trim(rs(2))%></span></span></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="3" align="center"></td>
</tr>
<tr>
<td height="1" align="center" background="images/line_hx.gif"></td>
</tr>
<tr>
<td height="5" align="center"></td>
</tr>
</table></td>
<%if i mod 4=0 then%></tr><tr><%end if%>'注意这裏,一行显示4个图片
<%
rs.movenext
wend
rs.close
set rs=nothing
%>
</tr>
<% end if %>
</table>
备注:楼主先看一下表格的效果,再控制每行显示4个.另既然准备一页显示5行的图片,为何
const ipp=12
rs.pagesize=ipp
有一点矛盾了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询