gusucode.com > asp+SQLServer网上书店系统设计(源代码+论文) > asp+SQLServer网上书店系统设计(源代码+论文)\网上书店asp+SQLServer\网上书店\displaybook.asp

    <!--#include file="conn.asp" -->
<script language=javascript>
function openurl(id) {   
window.open("bookpart.asp?book_ID="+id,"","height=400,width=630,left=200,top=0,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");}
function openbag(id) {   
window.open("eshop1.asp?cpbm="+id,"","height=430,width=630,left=200,top=0,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");
 }
</script>
<%
method=Trim(Request("method"))
set rs=server.createobject("adodb.recordset")
 bookname=Trim(Request("bookname"))
sqltext="select * from book " 
if method=1 then
sqltext=sqltext &" where  book_name like '%"& bookname&"%' "
else
sqltext=sqltext &" where  author like '%"& bookname&"%' "
end if
rs.open sqltext,cn,1,1
if rs.Eof then
  Response.redirect "login2.asp?msg=对不起目前书店还没有此书籍!"
else
dim MaxPerPage
MaxPerPage=3
'取得页数,并判断用户输入的是否数字类型的数据,如不是将以第一页显示
dim text,checkpage
text="0123456789"
 Rs.PageSize=MaxPerPage
for i=1 to len(request("page"))
   checkpage=instr(1,text,mid(request("page"),i,1))
   if checkpage=0 then
      exit for 
   end if
next

If checkpage<>0 then
      If NOT IsEmpty(request("page")) Then
         CurrentPage=Cint(request("page"))
        If CurrentPage < 1 Then CurrentPage = 1 end if
        If CurrentPage > Rs.PageCount Then CurrentPage = Rs.PageCount  end if
      Else
        CurrentPage= 1
      End If
      If not Rs.eof Then Rs.AbsolutePage = CurrentPage end if
Else
   CurrentPage=1
End if
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>书籍查找 </title>
<href="style.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>

<body>
以下你搜索结果
<hr color="black">
  <center>
        <div align="center">
          <table border="0" cellpadding="0" cellspacing="0" width="600"  height="92" >
            <tr>
              <td width="100%" height="70">
                <div align="center">
                  <table border="0" cellpadding="0" cellspacing="0" width="100%" height="148" >
                    <tr><td valign="top">

<div align="center">
  <table border="0" cellspacing="1" width="100%" bordercolorlight="#006699" bordercolordark="#FFFFFF"  height="55" bgcolor="#000000">
    <tr>
      <td width="16%" align="center" bgcolor="#006699" height="23"><font color="#FFFFFF">商品编号</font></td>
      <td width="34%" align="center" bgcolor="#006699" height="23"><font color="#FFFFFF">商品名称</font></td>
      <td width="18%" align="center" bgcolor="#006699" height="23"><font color="#FFFFFF">会员价</font></td>
      <td width="17%" align="center" bgcolor="#006699" height="23"><font color="#FFFFFF">详细信息</font></td>
      <td width="15%" align="center" bgcolor="#006699" height="23"><font color="#FFFFFF">购买</font></td>
    </tr>

 <% row_count=1 
   Sub list()%>
 <%i=0
 Do While Not rs.EOF%>
      <tr>                    
      <td width="16%" align="center" height="28" bgcolor="#EEEEEE"><%=rs("ID")%></td>
      <td width="34%" align="center" height="28" bgcolor="#EEEEEE" ><%=rs("book_Name")%></td>
      <td width="18%" align="center" height="28" bgcolor="#EEEEEE"><%=rs("book_price2")%></td>
      <td width="17%" align="center" height="28" bgcolor="#EEEEEE"><a href='javascript:openurl(<%=rs("ID")%>)'><font size=2>详细资料</font></td>
      <td width="15%" align="center" height="28" bgcolor="#EEEEEE"><a href='javascript:openbag(<%=rs("ID")%>)'>
<img border="0" src="images/mybuy.gif"></a></td>
    </tr>
 <%
   i=i+1
   if i >= MaxPerpage then exit do
	rs.MoveNext
   Loop
 end Sub
  %>
<% call list
   If Rs.recordcount > MaxPerPage then
   call showpages
 end if%>
  </table>
</div>
 				</td></tr>
                  </table>

     </div>
              </td>
            </tr>
          </table>
        </div>
<%
'显示翻页的子程序
sub showpages()%>
<table bgColor="#f8e8a0" border="0" cellPadding="0" cellSpacing="0" width="400" >  
<tr><td >
<form method="POST" action="displaybook.asp">
<input type="hidden" name="bookname" value="<%=bookname%>">
<table bgColor="#006699" border="0" cellPadding="0" cellSpacing="0" width="583" height="30">  
   <tr>
    <td  bgcolor="#eeeeee"  width="510">   
<font color="#000000">   
<p align="center">   
<%  
   If currentpage > 1 Then
      response.write "<a href='allbook1.asp?page1=cstr(1)'><font color='#000000'>第1页</font></a><font color='#000000'><b>-</b></font>"  
      Response.write "<a href='allbook1.asp?page1=Cstr(currentpage-1)'><font color='#000000'>前1页</font></a><font color='#000000'><b>-</b></font>"
   Else
      Response.write "<font color='#000000'>第1页-</font>"
      Response.write "<font color='#000000'>前1页-</font>" 
   End if
   
   If currentpage < Rs.PageCount Then
      Response.write "<a href='allbook1.asp?page1=Cstr(currentpage+1)'><font color='#000000'>后1页</font></a><font color='#000000'><b>-</b></font>"
      Response.write "<a href='allbook1.asp?page1=Cstr(rs.pageCount)'><font color='#000000'>尾页</font></a>&nbsp;&nbsp;"
   Else
      Response.write "<font color='#000000'>后页-</font>"
      Response.write "<font color='#000000'>尾页</font>&nbsp;&nbsp;"       
   End if
   Response.write "<font color='#000000'>页次:</font>" & "<font color=#FF0000>" & Cstr(CurrentPage) &  "</font>" & "<font color='#000000'>/" & Cstr(rs.pagecount) & "</font>&nbsp;"
   Response.write "<font color=#ff0000>" & Cstr(MaxPerPage) & "</font>" & "<font color='#000000'>种商品/页&nbsp" & "共</font>" & "<font color=#FF0000>" & Cstr(Rs.RecordCount) & "</font>" & "<font color='#000000'>种商品</font>&nbsp;&nbsp;"

response.write "</td><td align='right'>"
response.write "<font color='#000000' >到:</font><input type='text' name='page' size=2 maxlength=3 class=smallInput value="&Currentpage&">&nbsp;"
   response.write "<input class=buttonface type='submit'  value='Go'  name='cndok' style='background-color: #eeeeee'></span>"
%>    
</font>    
    </td>  
   </tr>
  </table>
  </center>
</td></tr>
</table>
</form>
<%end sub%>
<%end if%>
</body>
</html>