注册 登录
编程论坛 ASP技术论坛

asp分页:第一页没问题,但是按别的按钮(首页,下一页等)就会变成搜索全部

aaa8787aaa 发布于 2016-01-11 16:28, 3786 次点击
" onfocus="this.value=''" onblur="if(!value){value=defaultValue;}">
这是搜索框的代码
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 <% dim bigname,sname
                sqlnews="select * from product where title like '%"&request("keyword")&"%'"
                        
                         set rss=server.CreateObject("adodb.recordset")
                        
                         rss.open sqlnews,conn,3,3
                              set rs=getrecordset(sqlnews)
                             if not ( rs.eof and rs.bof ) then
                             bigname=rs("bigclassname")
                             sname=rs("smallclassname")
                              %>
 这是查询代码        
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
这是分页代码


                        
                            " name="gotopage" class="f12 STYLE2" id="gotopage">
                            <%if rsrecordcount="" then
                                    showcount=0
                                    else
                                    showcount=rsrecordcount
                                    end if
                                    %> 总共有<%=showcount%>张图片
                                    <%
                                     if (rsrecordcount mod rspagesize)=0 then
                                    allpage=int(Cint(rsrecordcount)/rspagesize)
                                    else
                                    allpage=int(Cint(rsrecordcount)/rspagesize)+1
                                    end if
                                    if allpage=0 then
                                    allpage=1
                                    end if
                                    showpages=1
                                    if not isempty(request("page")) then
                                    titlepage=Cint(request("page"))
                                    showpages=Cint(titlepage/rspagesize)+1
                                    end if
                                    if showpages=0 then
                                    showpages=1
                                    end if
                                    %>
                                    第<%=showpages%>/<%=allpage%>页
                            <%if page>=0 then%>
                            ?page=0&bigclassname=<%=request("bigclassname")%>&title=<%=request("keyword")%>">首页
                            <%else%>
                              首页
                              <%end if%>
                                
                          <% if page>1 then %>
                              ?page=<%=page-rspagesize%>&bigclassname=<%=request("bigclassname")%>&title=<%=request("keyword")%>">上页
                              <%else%>
                              上页
                              <%end if%>
                                
                          <% if page
                              ?page=<%=page+rspagesize%>&bigclassname=<%=request("bigclassname")%>&title=<%=request("keyword")%>">下页
                              <%else%>
                              下页
                              <%end if%>
                                
                          <%if page
                              ?page=<%=rspagecount*rspagesize%>&bigclassname=<%=request("bigclassname")%>&title=<%=request("keyword")%>">尾页
                              <%else%>
                              尾页
                          <%end if %>
                              " />" />
   
    <%
    if request("page")<>"" then
    crruectpage=Cint(request("page"))
    %>
      " selected="selected">第<%=Int(crruectpage/rspagesize)+1%>页
     <%end if%>
    <%
    i=0
    do while i
   
     " >第<%=i+1%>页
      <% i=i+1
    loop %>
   
                              
                          
                          
                        
            
6 回复
#2
hu9jj2016-01-11 18:14
#3
tlliqi2016-01-11 20:59
netlin 的方法可行
#4
aaa8787aaa2016-01-12 17:13
还是不懂,求大神们帮我修改一下
#5
aaa8787aaa2016-01-12 17:15
---------------------------------------------------------
<!--#include file="inc/conn.asp"-->
<%
sql="select * from Affiche"
set rss=server.createobject("adodb.recordset")
rss.open sql,conn,1,1
这是链接数据库
-----------------------------------------
#6
aaa8787aaa2016-01-12 17:22
我从新发一次新的,求大神们帮我改改
-------------------------------------------------------------------------------------------------------------
    <form name="form1" action="shousuo.asp" method="get"><input name="keyword" type="text" class="a" value="" onfocus="this.value=''" onblur="if(!value){value=defaultValue;}" ><input type="submit" name="Submit" value="" class="b" onclick="btn_ck_bh_Click()"></form>
这是搜索框代码
--------------------------------------------------------------------------------------------------------------
<!--#include file="inc/conn.asp"-->
<%
sql="select * from Affiche"
set rss=server.createobject("adodb.recordset")
rss.open sql,conn,1,1
%>
这是数据库连接
-------------------------------------------------------------------------------------------------------
 <%
                dim bigname,sname
                cx = request("keyword")
                sqlnews="select * from product where title like '%"&cx&"%'"
                set rss=server.CreateObject("adodb.recordset")
                rss.open sqlnews,conn,1,3
                set rs=getrecordset(sqlnews)
                if not ( rs.eof and rs.bof ) then
                bigname=rs("bigclassname")
                sname=rs("smallclassname")
                %>               
这是接收和查询代码
---------------------------------------------------------------------------
 <%
        dim j,rspagesize,rspagecount,Page,rsrecordcount
        rspagesize=6
        j=rspagesize
        while not rs.eof
        rs.movenext
        rsrecordcount=rsrecordcount+1
        wend
        rs.movefirst
        rspagecount=int(rsrecordcount/rspagesize)
        Page=int(request("page"))
        if (page<>0) and(Page<=rsrecordcount) then
        rs.move Page
        end if
        %>   
         <tr>
        <%
k=0  
While (j<>0)and(NOT(rs.eof))
%>
<%
 if k<3 then
%>
------------------------------------------------------------------------------------
这里是内容,省略.........
-----------------------------------------------------------------------------------
 <%
k=k+1
j=j-1
rs.MoveNext()
%>   
 <%else
k=0%>
--------------------------------------------------------------------------------------
<%end if %>
                                        <%WEnd%>
                                      
                                   
           <%
        end if
        rs.close
        set rs=nothing
        'call CloseConn

        %>
----------------------------------------------------------------------------------------------
  <%if page>=0 then%>
                            <a href="<%=request.ServerVariables("PATH_INFO")%>?page=0&bigclassname=<%=request("bigclassname")%>&smallclassname=<%=sname%>">首页</a>
                            <%else%>
                              首页
                              <%end if%>
                              &nbsp;&nbsp;
                          <% if page>1 then %>
                              <a href="<%=request.ServerVariables("PATH_INFO")%>?page=<%=page-rspagesize%>&bigclassname=<%=request("bigclassname")%>&smallclassname=<%=sname%>">上页</a>
                              <%else%>
                              上页
                              <%end if%>
                              &nbsp;&nbsp;
                          <% if page<rsrecordcount-rspagesize then %>
                              <a href="<%=request.ServerVariables("PATH_INFO")%>?page=<%=page+rspagesize%>&bigclassname=<%=request("bigclassname")%>&smallclassname=<%=sname%>">下页</a>
                              <%else%>
                              下页
                              <%end if%>
                              &nbsp;&nbsp;
                          <%if page<rsrecordcount-rspagesize then%>
                              <a href="<%=request.ServerVariables("PATH_INFO")%>?page=<%=rspagecount*rspagesize%>&bigclassname=<%=request("bigclassname")%>&smallclassname=<%=sname%>">尾页</a>
                              <%else%>
                              尾页
                          <%end if %></span>
这里是分页代码
----------------------------------------------------------------------------------------------------------------------------------
#7
神赐金勋2016-02-05 21:37
关键得懂分页思想
得多想
1