标题:求助! 向高手请教
只看楼主
djz168
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-1-16
 问题点数:0 回复次数:3 
求助! 向高手请教
我的asp分页,始终显示的是一页,点上一页,下一页,首页,最后一页,全都是显示的那一页.
在地址栏上的地址是:http://localhost/123/product.asp?page=2&classid=&nclassid=&skey=
如果我在地址栏的"="号后页输入2或3则可以显示另外的内容.skey的值没有到到.以下是分页代码,请高手指点
搜索更多相关主题的帖子: localhost 地址栏 
2008-06-29 07:46
djz168
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-1-16
得分:0 
求助! 向高手请教asp分页问题
求助! 向高手请教
我的asp分页,始终显示的是一页,点上一页,下一页,首页,最后一页,全都是显示的那一页.
在地址栏上的地址是:http://localhost/123/product.asp?page=2&classid=&nclassid=&skey=
如果我在地址栏的"="号后页输入2或3则可以显示另外的内容.skey的值没有到到.以下是分页代码,请高手指点
<table width="100%" border="0" cellpadding="0" cellspacing="0">
                                        <tr>
                                          <% set frs=server.CreateObject("adodb.recordset")
'                       if request("skey")<>"" then
'                            sql="select * from product where typeid="& request("menu1")&" and product like'%"& request("skey") & "%' order by paixu desc"
'                        else
'                         classid=request("classid")
'                    if classid<>"" or request("nclassid")<>"" then
'                       if classid<>"" and request("nclassid")<>"" then
'                          sql="select * from product where typeid="& classid & " and ntypeid=" & request("nclassid") & " order by paixu desc"
'                        elseif classid<>"" and request("nclassid")="" then
'                           sql="select * from product where typeid=" & classid&" order by paixu desc"
'                         elseif classid="" and request("nclassid")<>"" then
'                           sql="select * from product where ntypeid="& request("nclassid")&" order by paixu desc"
'                         end if
                    
'                    else
'                      sql="select * from product order by paixu desc"
'                    end if
'                   end if
if request("classid")<>"" then
    ji=" and typeid="&request("classid")
else
    if request("nclassid")<>"" then
    ji=" and ntypeid="&request("nclassid")
    else    
    ji=" and typeid<>37 "
    end if
end if
if trim(request("skey"))<>"" then
    ji1=" and product like '%"&request("skey")&"%'"
else
    ji1=""
end if
sql="select * from product where id is not null "
sql=sql+ji+ji1+" order by paixu desc"
'response.Write(sql)
'response.End()
                     frs.open sql,con,1,1
                     %>
                                          <td valign="top"><%
if frs.bof or frs.eof then
    response.write"<font color=red>娌℃湁鍙戝竷浜у搧锛?/font>"
    'response.end
else
  if request("page")="" then
     page=1
   else
     page=request("page")
   end if%>
                                              <% if Trim(Request.Form("skey"))<>"" then
set frs=server.CreateObject("adodb.recordset")
    sql = "select * from product where product like '%"&Trim(Request.Form("skey"))&"%' order by id desc"
    'response.write sql
    'response.end()
   frs.open sql,con,1,1
end if

   
if frs.eof then
    response.Write("没有记录!")
    response.End()
end if%>
                                              <% '=request("text")%>
                                              <% if trim(request("text"))<>"" then
'response.Write(request("text"))
        if cint(request("text"))<1 then
           page=1
        elseif cint(request("text"))>cint(request("rsmax")) then
           page=int(request("rsmax"))
        else
           page=request("text")
        end if
      end if
      'response.Write(page)
   frs.pagesize=12
   frs.AbsolutePage=page%>
                                              <table width="100%"  border="0" align="center" cellpadding="00" cellspacing="0">
                                                <tr>
                                                  <td width="494" height="261" align="center" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                                                      <tr>
                                                        <td valign="top" background="images/ban_29.jpg"><span class="STYLE12">New Product </span></td>
                                                      </tr>
                                                    </table>
                                                      <table width="51%"  border="0" cellspacing="10" cellpadding="0">
                                                        <tr>
                                                          <td height="210" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                                                              <tr>
                                                                <% set frs=server.CreateObject("adodb.recordset")
'                       if request("skey")<>"" then
'                            sql="select * from product where typeid="& request("menu1")&" and product like'%"& request("skey") & "%' order by paixu desc"
'                        else
'                         classid=request("classid")
'                    if classid<>"" or request("nclassid")<>"" then
'                       if classid<>"" and request("nclassid")<>"" then
'                          sql="select * from product where typeid="& classid & " and ntypeid=" & request("nclassid") & " order by paixu desc"
'                        elseif classid<>"" and request("nclassid")="" then
'                           sql="select * from product where typeid=" & classid&" order by paixu desc"
'                         elseif classid="" and request("nclassid")<>"" then
'                           sql="select * from product where ntypeid="& request("nclassid")&" order by paixu desc"
'                         end if
                    
'                    else
'                      sql="select * from product order by paixu desc"
'                    end if
'                   end if
if request("classid")<>"" then
    ji=" and typeid="&request("classid")
else
    if request("nclassid")<>"" then
    ji=" and ntypeid="&request("nclassid")
    else    
    ji=" and typeid<>37 "
    end if
end if
if trim(request("skey"))<>"" then
    ji1=" and product like '%"&request("skey")&"%'"
else
    ji1=""
end if
sql="select * from product where id is not null "
sql=sql+ji+ji1+" order by paixu desc"
'response.Write(sql)
'response.End()
                     frs.open sql,con,1,1
                     %>
                                                                <td valign="top"><table width="441" height="189" border="0" cellpadding="0" cellspacing="0">
                                                                    <%
  n=1
  do while n<=5 and not frs.eof%>
                                                                    <tr>
                                                                      <td height="189" colspan="4"><img src="images/bk_b_04.jpg" width="1" height="1" />
                                                                          <table width="51%" height="169"
                  border="0" align="center" cellpadding="0" cellspacing="0">
                                                                            <tbody>
                                                                              <tr>
                                                                                <td width="177" valign="middle"><table width="165" border="0" align="center" cellpadding="0" cellspacing="0">
                                                                                    <tbody>
                                                                                      <tr>
                                                                                        <td width="6"><img height="6"
                              src="images/bk_j_01.jpg"
                              width="6" /></td>
                                                                                        <td width="150"
                            background="images/bk_b_01.jpg"></td>
                                                                                        <td width="10"><img height="6"
                              src="images/bk_j_02.jpg"
                              width="6" /></td>
                                                                                      </tr>
                                                                                      <tr>
                                                                                        <td
                            background="images/bk_b_02.jpg"
                            height="155"></td>
                                                                                        <td align="center"><a href="m_ViewImage.asp?ProductID=<%=frs("id")%>&user=<%=session("user")%>" target="_blank"><img src="./cx/upImg/<%=frs("img1")%>" alt="" width="150" height="150" border="0" style="border-color:#57A093 " /></a></td>
                                                                                        <td
                            background="images/bk_b_03.jpg"></td>
                                                                                      </tr>
                                                                                      <tr>
                                                                                        <td><img height="6"
                              src="images/bk_j_03.jpg"
                              width="6" /></td>
                                                                                        <td
                            background="images/bk_b_04.jpg"></td>
                                                                                        <td><img height="6"
                              src="images/bk_j_04.jpg"
                              width="6" /></td>
                                                                                      </tr>
                                                                                    </tbody>
                                                                                </table></td>
                                                                                <td valign="top" width="306"><table cellspacing="0" cellpadding="0" width="300" border="0">
                                                                                    <tbody>
                                                                                      <tr>
                                                                                        <td width="6"><img height="6"
                              src="images/bk_j_01.jpg"
                              width="6" /></td>
                                                                                        <td
                            background="images/bk_b_01.jpg"
                            colspan="2"></td>
                                                                                        <td width="11"><img height="6"
                              src="images/bk_j_02.jpg"
                              width="6" /></td>
                                                                                      </tr>
                                                                                      <tr>
                                                                                        <td
                            background="images/bk_b_02.jpg"></td>
                                                                                        <td class="main" width="258" bgcolor="#f8f8f8"
                              height="20"><a href="M_ViewImage.asp?ProductID=<%=frs("id")%>&amp;user=<%=session("user")%>" target="_blank"><%=frs("product")%></a></td>
                                                                                        <td width="32" bgcolor="#f8f8f8"><table cellspacing="0" cellpadding="0" width="100%"
                              border="0">
                                                                                            <tbody>
                                                                                              <tr>
                                                                                                <td align="right" width="42%"><img
                                height="16"
                                src="images/an_more.jpg"
                                width="32"
border="0" /></td>
                                                                                              </tr>
                                                                                            </tbody>
                                                                                        </table></td>
                                                                                        <td
                            background="images/bk_b_03.jpg"></td>
                                                                                      </tr>
                                                                                      <tr>
                                                                                        <td><img height="6"
                              src="images/bk_j_03.jpg"
                              width="6" /></td>
                                                                                        <td
                            background="images/bk_b_04.jpg"
                            colspan="2"></td>
                                                                                        <td><img height="6"
                              src="images/bk_j_04.jpg"
                              width="6" /></td>
                                                                                      </tr>
                                                                                    </tbody>
                                                                                  </table>
                                                                                    <table cellspacing="0" cellpadding="0" width="169" border="0">
                                                                                      <tbody>
                                                                                        <tr>
                                                                                          <td width="169" height="5"></td>
                                                                                        </tr>
                                                                                      </tbody>
                                                                                    </table>
                                                                                  <table width="300" border="0" cellpadding="0" cellspacing="0">
                                                                                      <tbody>
                                                                                        <tr>
                                                                                          <td width="6" height="6"><img height="6"
                              src="images/bk_j_01.jpg"
                              width="6" /></td>
                                                                                          <td width="378"
                            background="images/bk_b_01.jpg"></td>
                                                                                          <td width="10"><img height="6"
                              src="images/bk_j_02.jpg"
                              width="6" /></td>
                                                                                        </tr>
                                                                                        <tr>
                                                                                          <td
                            background="images/bk_b_02.jpg"></td>
                                                                                          <td width="378" height="95" valign="top"><a href="M_ViewImage.asp?ProductID=<%=frs("id")%>&amp;user=<%=session("user")%>" target="_blank"><%=left(ltrim(frs("remark")),400)%></a></td>
                                                                                          <td
                            background="images/bk_b_03.jpg"></td>
                                                                                        </tr>
                                                                                        <tr>
                                                                                          <td height="6"><img height="6"
                              src="images/bk_j_03.jpg"
                              width="6" /></td>
                                                                                          <td
                            background="images/bk_b_04.jpg"></td>
                                                                                          <td><img height="6"
                              src="images/bk_j_04.jpg"
                              width="6" /></td>
                                                                                        </tr>
                                                                                      </tbody>
                                                                                  </table></td>
                                                                              </tr>
                                                                            </tbody>
                                                                        </table></td>
                                                                    </tr>
                                                                    <%frs.movenext
     n=n+1
    loop
    %>
                                                                </table></td>
                                                              </tr>
                                                          </table></td>
                                                        </tr>
                                                    </table></td>
                                                </tr>
                                              </table>
                                              <table width="100%" border="0" cellspacing="3" cellpadding="0">
                                                <tr>
                                                  <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                                      <tr>
                                                        <td height="5"><img src="../images/dian.gif" width="1" height="1" /></td>
                                                      </tr>
                                                      <tr>
                                                        <td height="2" bgcolor="#CCCCCC"><img src="../images/dian.gif" width="1" height="1" /></td>
                                                      </tr>
                                                    </table>
                                                      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" >
                                                        <tr>
                                                          <td width="10%" height="36" align="left"><% d="&skey="&request("skey")%>
                                                              <div align="center"><a href="product.asp?page=1&amp;classid=<%=request("classid")%>&amp;nclassid=<%=request("nclassid")%><%=d%>"><font color="#000000">首页</font></a></div></td>
                                                          <td width="13%" align="left"><div align="center">
                                                              <% if page>1 then%>
                                                              <a href="product.asp?page=<%=page-1%>&amp;classid=<%=request("classid")%>&amp;nclassid=<%=request("nclassid")%><%=d%>"> <font color="#000000">上一页</font></a>
                                                              <% else %>
                                                              <%="----"%>
                                                              <% end if%>
                                                          </div></td>
                                                          <td width="12%" align="left"><div align="center">
                                                              <%if cint(page)<cint(frs.pagecount) then%>
                                                              <a href="product.asp?page=<%=page+1%>&classid=<%=request("classid")%>&nclassid=<%=request("nclassid")%><%=d%>"> <font color="#000000">下一页</font></a>
                                                              <% else %>
                                                              <%="----"%>
                                                              <% end if%>
                                                          </div></td>
                                                          <td width="10%" align="left"><div align="center"> <a href="product.asp?page=<%=frs.pagecount%>&amp;classid=<%=request("classid")%>&amp;nclassid=<%=request("nclassid")%><%=d%>"> <font color="#000000">末页</font></a></div></td>
                                                          <td width="13%" align="left"><div align="center">共:<span class="newform"><%=frs.pagecount%></span>页</div></td>
                                                          <td width="17%" align="left"><div align="center">当前第<span class="newform"><%=page%></span>页</div></td>
                                                          <form action="product.asp" method="post" name="form3" id="form3">
                                                            <td width="13%" align="left" valign="middle"><div align="center">
                                                                <input name="text" type="text" class="i1" id="text" size="3" maxlength="3" />
                                                              页 </div></td>
                                                            <td width="12%" align="left" valign="middle"><div align="center">
                                                                <input name="nclassid" type="hidden" id="nclassid" value="<%=request("nclassid")%>" />
                                                                <input name="classid" type="hidden" id="classid" value="<%=request("classid")%>" />
                                                                <input name="rsmax" type="hidden" id="rsmax" value="<%=frs.pagecount%>" />
                                                                <input name="Submit6" type="submit" class="input2" id="Submit6" value="GO" />
                                                            </div></td>
                                                          </form>
                                                        </tr>
                                                    </table></td>
                                                </tr>
                                              </table>  
                                              <% End If %>
                                          </td>
                                        </tr>
                                    </table>
2008-06-29 07:48
multiple1902
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:4881
专家分:671
注 册:2007-2-9
得分:0 
没时间看完你的代码,基本思想我想是这样的:先获取当前页面号码,如果是不合法的(比如没有提供)那么认为是第一页,然后输出“上一页”链接的前提是“不是第一页”,输出“下一页”链接的前提是“不是最后一页”,输出这几个链接的时候链接里要包含【当前页面号-1】和【当前页面号+1】作为查询字符串里skey的取值,你看看是不是这一步漏了。
2008-06-29 08:56
icecool
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:20
帖 子:1214
专家分:1366
注 册:2005-3-14
得分:0 
<a href=product.asp?page=<%=page+1%>&classid=<%=request("classid")%>&nclassid=<%=request("nclassid")%>&skey=<%=request("skey")%>>下一页</a>

http://toorup.3v.do
loading...
2008-06-29 13:57



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-221799-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.530525 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved