日期:2014-05-17  浏览次数:21231 次

查询结果分页
从数据表中读取所有的单据记录,然后进行分页显示:页面跳转的功能就是使用 “首页”“上一页”“下一页”“尾页”进行页面之间的跳转;在这个页面中,分页显示正常; 
但是,我想在查询结果显示页面中也实现类似的功能,因为功能类似,所以我也使用了类似的分页显示;但是,问题却出现了: 
当我输入查询关键字,点击查询以后,返回的查询结果集是正常的;但是,当我点击“上一页”或者“下一页”时,显示的记录集却变成了所有的记录集;而不是查询结果集中的记录。 
我知道是没把查询的关键字传过去的原因 但是我的关键字是跟查询方式有关的 如果不知道查询方式 光将关键字传过去也没用
唉!我刚学ASP很多地方都不会!请高手救命呀!


代码如下:
 sql="select * from yssj " //从数据库中将所有数据查询出来
  if nowsel="1" then //根据列表判断查询方式
  sql=sql&"where AD like '%"&nowkeyword&"%'" //更改查询条件
  end if  
  if nowsel="2" then //根据列表判断查询方式
  sql=sql&"where YE like '%"&nowkeyword&"%'" //更改查询条件
  end if  
  sql=sql&" order by id"  





 <tr>
  <%if rs.pagecount > 0 then%>
  <td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>  
  <%else%>
  <td width="41%" align="left">当前页0/0</td><%end if%>
  <td width="46%" align="right"> <a href="pri_ys.asp?page=1">首页</a>| //当前页
  <%if pre then%>
  <a href="pri_ys.asp?page=<%=intpage -1%>">上页</a>| <%end if%> //跳转上一页
  <%if last then%>
  <a href="pri_ys.asp?page=<%=intpage +1%>">下页</a> |<%end if%> //跳转下一页
  <a href="pri_ys.asp?page=<%=rs.PageCount%>">尾页</a>|转到第
  <select name="sel_page" onChange="javascript:location=this.options[this.selectedIndex].value;"> //选择跳转第i页
  <%
  for i = 1 to rs.PageCount
  if i = intpage then%>
  <option value="pri_ys.asp?page=<%=i%>" selected><%=i%></option>
  <%else%>
  <option value="pri_ys.asp?page=<%=i%>"><%=i%></option>
  <%
  end if
  next
  %>
  </select>页</font> 
  </td>
  </tr>

------解决方案--------------------
页面翻页时,页面刷新了,你之前输入查询的关键字不在了。
------解决方案--------------------
<tr>
<%if rs.pagecount > 0 then%>
<td width="13%" align="left">当前页<%=intpage%>/<%=rs.PageCount%></td>
<%else%>
<td width="41%" align="left">当前页0/0</td><%end if%>
<td width="46%" align="right"> <a href="pri_ys.asp?page=1&nowkeyword=<%=nowkeyword%>">首页</a>| //当前页
<%if pre then%>
<a href="pri_ys.asp?page=<%=intpage -1%>&nowkeyword=<%=nowkeyword%>">上页</a>| <%end if%> //跳转上一页
<%if last then%>
<a href="pri_ys.asp?page=<%=intpage +1%>&nowkeyword=<%=nowkeyword%>">下页</a> |<%end if%> //跳转下一页
<a href="pri_ys.asp?page=<%=rs.PageCount%>&nowkeyword=<%=nowkeyword%>">尾页</a>|转到第
<select name="sel_page" onChange="javascript:location=this.options[this.selectedIndex].value;"> //选择跳转第i页
<%
for i = 1 to rs.PageCount
if i = intpage then%>
<option value="pri_ys.asp?page=<%=i%>&nowkeyword=<%=nowkeyword%>" selected><%=i%></option>
&l