您的位置:程序门 -> web 开发 -> asp



又是循环搞不懂了郁闷


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


又是循环搞不懂了郁闷
发表于:2007-01-03 16:15:11 楼主
下面的实现应该是

图片1   图片1   图片1
说明1   说明1   说明1

图片1   图片1   图片1
说明1   说明1   说明1

图片1   图片1   图片1
说明1   说明1   说明1
        分页
  有错误,我点上一页或下一页,首页,尾页的时候始终是在本页,而不是下一条记录


<tr>
<td   height= "600 "   align= "center "   valign= "top "   style= "word-break:break-all "   >
<%  
const   maxperpage=5   '分页显示的纪录个数  
dim   sql  
dim   rs  
dim   totalput  
dim   currentpage  
dim   totalpages  
dim   i,j  
 
 
if   not   isempty(request( "page "))   then  
currentpage=cint(request( "page "))  
else  
currentpage=1  
end   if  
set   rs=server.createobject( "adodb.recordset ")  
sql= "select   *   from   honor   order   by   id   desc "  
rs.open   sql,conn,1,1  
 
if   rs.eof   and   rs.bof   then  
response.write   " <p   align= 'center '> 还没有任何留言! </p> "  
else    
totalput=rs.recordcount  
if   currentpage <1   then  
currentpage=1  
end   if  
if   (currentpage-1)*maxperpage> totalput   then  
if   (totalput   mod   maxperpage)=0   then  
currentpage=   totalput   \   maxperpage  
else  
currentpage=   totalput   \   maxperpage   +   1  
end   if  
end   if  
if   currentpage=1   then    
showcontent  
showpages  
else  
if   (currentpage-1)*maxperpage <totalput   then  
rs.move   (currentpage-1)*maxperpage  
dim   bookmark  
bookmark=rs.bookmark    
showcontent  
showpages  
else  
currentpage=1  
showcontent  
end   if  
end   if  
rs.close  
end   if  
set   rs=nothing  
conn.close  
set   conn=nothing  
sub   showcontent  
dim   i  
i=0  
do   while   not   (rs.eof   or   err)   %>
<table   width= "100% "   align= "center "   valign= "middle ">

<tr>
<%
set   rs1=server.createobject( "adodb.recordset ")
sql1= "select   *   from   honor   order   by   id   desc "
rs1.open   sql1,conn,1,1
i=1
j=0
do   while   not   rs.eof
    if   j/9 <> 1   then
        if   i   mod   3=0   then  
%>

<td   align= "center "   valign= "middle "> <table   id= "__01 "   width= "172 "   height= "133 "   border= "0 "   cellpadding= "0 "   cellspacing= "0 "> <tr> <td   colspan=4> &nbsp; </td> </tr>
                            <tr>
                                <td   colspan= "3 "> <img   src= "images/index_03_02_03_05_02_03_01.jpg "   width= "172 "   height= "7 "   alt= " "> </td>
                            </tr>
                            <tr>
                                <td   rowspan= "2 "> <img   src= "images/index_03_02_03_05_02_03_02.jpg "   width= "6 "   height= "126 "   alt= " "> </td>
                                <td   width= "160 "   height= "119 "   align= "center "> <a   href=hjshow.asp?id= <%=rs1( "id ")%> > <img   src= <%=rs1( "img ")%>   width= "159 "   height= "118 "> </a> </td>
                                <td   rowspan= "2 "> <img   src= "images/index_03_02_03_05_02_03_04.jpg "   width= "6 "   height= "126 "   alt= " "> </td>
                            </tr>
                            <tr>
                                <td> <img   src= "images/index_03_02_03_05_02_03_05.jpg "   width= "160 "   height= "7 "   alt= " "> </td>
                            </tr>
                            <tr>
                                <td   align= "center "   colspan= "3 "> <table   width= "100% ">
                                    <tr>
                                        <td> <img   src=img/new_title.jpg> </td>
                                        <td> <strong> <font   color= "red ">
                                                <%if   len(rs1( "title "))> 12   then%>
                                            <%=left(rs1( "title "),12)%> ...
                                            <%else%>
                                            <%=rs1( "title ")%>
                                            <%end   if%>
                                        </font> </strong>   </td>
                                    </tr>
                                </table> </td>
                            </tr>
                        </table> </td> </tr> <tr>
<%
    j=j+1
    else
  %>
  <td   align= "center "   valign= "middle "> <table   id= "__01 "   width= "172 "   height= "133 "   border= "0 "   cellpadding= "0 "   cellspacing= "0 "> <tr> <td   colspan=4> &nbsp; </td> </tr>
                            <tr>
                                <td   colspan= "3 "> <img   src= "images/index_03_02_03_05_02_03_01.jpg "   width= "172 "   height= "7 "   alt= " "> </td>
                            </tr>
                            <tr>
                                <td   rowspan= "2 "> <img   src= "images/index_03_02_03_05_02_03_02.jpg "   width= "6 "   height= "126 "   alt= " "> </td>
                                <td   width= "160 "   height= "119 "   align= "center "> <a   href=hjshow.asp?id= <%=rs1( "id ")%> > <img   src= <%=rs1( "img ")%>   width= "159 "   height= "118 "> </a> </td>
                                <td   rowspan= "2 "> <img   src= "images/index_03_02_03_05_02_03_04.jpg "   width= "6 "   height= "126 "   alt= " "> </td>
                            </tr>
                            <tr>
                                <td> <img   src= "images/index_03_02_03_05_02_03_05.jpg "   width= "160 "   height= "7 "   alt= " "> </td>
                            </tr>
                            <tr>
                                <td   align= "center "   colspan= "3 "> <table   width= "100% ">
                                    <tr>
                                        <td> <img   src=img/new_title.jpg> </td>
                                        <td> <strong> <font   color= "red ">
                                                <%if   len(rs1( "title "))> 12   then%>
                                            <%=left(rs1( "title "),12)%> ...
                                            <%else%>
                                            <%=rs1( "title ")%>
                                            <%end   if%>
                                        </font> </strong>   </td>
                                    </tr>
                                </table> </td>
                            </tr>
                        </table> </td>
  <%
j=j+1
end   if
rs1.movenext
i=i+1
else
exit   do
end   if
loop
  %>
  <tr> <td> &nbsp; </td> </tr>
  <tr>
      <td   colspan= "2 "   align= "center ">
     
                            <%   i=i+1  
if   i> =maxperpage   then   exit   do  
rs.movenext  
loop  
end   sub  
sub   showpages()  
dim   n  
if   (totalput   mod   maxperpage)=0   then  
n=   totalput   \   maxperpage  
else  
n=   totalput   \   maxperpage   +   1  
end   if  
dim   k  
 
if   currentpage=1   then  
%>
首页   上一页
<%
else  
%>
<a   href=hjzs.asp?page=1> 首页 </a>
<a   href=hjzs.asp?page= <%=(currentpage-1)%> > 上一页 </a>
<%
end   if  
if   n-currentpage <1   then
%>
下一页   尾页
<%else%>

<a   href=hjzs.asp?page= <%=(currentpage+1)%> > 下一页 </a>
<a   href=hjzs.asp?page= <%=n%> > 尾页 </a>
<%
end   if

end   sub  
%>
 
      </td>
  </tr>
</table>
</td>
</tr>
发表于:2007-01-03 19:57:361楼 得分:0
代码长     不知道你的问题所在!
发表于:2007-01-03 20:28:022楼 得分:0
把我给看晕了
发表于:2007-01-03 20:29:213楼 得分:0
就是一个图片循环和一个分页


快速检索

最新资讯
热门点击