search.asp

来自「自己做的毕业设计」· ASP 代码 · 共 212 行

ASP
212
字号
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>图书馆管理系统</title>
<link href="css.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
body {
	background-color: #E7EEF5;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
.STYLE2 {
	font-size: 16px;
	font-family: "黑体";
	color: #FFFFFF;
}
.tb2{
	margin-top: 3px;
	margin-right: 0px;
	margin-bottom: 3px;
	margin-left: 0px;
}
.style4 {font-size: 16px; font-family: "黑体"; color: #000000; }
-->
</style>
</head>
<!--#include file="conn.asp"-->
<%
key=trim(request.Form("key"))
type1=trim(request.Form("type"))
lb=trim(request.Form("lb"))

		sql="select * from [book]"
		
		select case type1
		case "1"
		tt="[b_name]"
		case "2"
		tt="[b_WRITER]"
		case "3"
		tt="[b_CONCERN]"
		case "4"
		tt="[b_ISBN]"
		end select
		
		select case trim(request.Form("px"))
		case "1"
		p="asc"
		case "2"
		p="desc"
		end select
		
		if lb="" and key="" then
		sql=sql&" order by [b_CHECK_DATE] "&p&""
		elseif  lb<>"" and key="" then
		sql=sql&" where [b_SORT]="&lb&" order by [b_CHECK_DATE]  "&p&""
		elseif  lb<>"" and key<>"" then
		sql=sql&" where [b_SORT]="&lb&" and "&tt&" like '%"&key&"%' order by [b_CHECK_DATE]  "&p&""
		elseif  lb="" and key<>"" then
		sql=sql&" where "&tt&" like '%"&key&"%' order by [b_CHECK_DATE]  "&p&""
		else
		end if	
		
		
		set rs=server.createobject("adodb.recordset")
		rs.open sql,conn,1,1
%>
<body>
<form name="form1" method="post" action="">
<center>
<table width="800" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="150"><!--#include file="top.asp"--></td>
  </tr>
  <tr>
    <td align="center" valign="top"><table width="100%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#C5D5E4" class="tb2">
<tr>
                            <td height="38" valign="top"><table width="100%"  border="0">
                                <tr></tr>
                              </table>
                                <table width="100%"  border="0" cellpadding="0" cellspacing="0">
                                  <tr>
                                    <td width="94%" valign="top"><table width="100%" align="center" border="0" cellspacing="0" cellpadding="0" >
<tr>
                                            <td height="30" align="center" valign="middle" background="img/T_bg.gif" class="title_bg"><span class="style4">查询结果</span></td>
                                      </tr>
                                          <tr>
                                            <td valign="top">
											<%
		if rs.recordcount=0 then %>
                                <table width="100%" border="0" cellspacing="0" cellpadding="5" align="center">
                                                  <tr>
                                                    <td align="center">暂无符合该条件的信息,请更换查询条件!</td>
                                                  </tr>
                                              </table>
<%
		else
	  		rs.PageSize =10
			iCount=rs.RecordCount 
			iPageSize=rs.PageSize
    		maxpage=rs.PageCount 
    		page=request.QueryString("page")
    if Not IsNumeric(page) or page="" then
        page=1
    else
        page=cint(page)
    end if
    if page<1 then
        page=1
    elseif  page>maxpage then
        page=maxpage
    end if
    rs.AbsolutePage=Page
	if page=maxpage then
		x=iCount-(maxpage-1)*iPageSize
	else
		x=iPageSize
	end if
	%>
                                <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#E7EEF5">
<tr>
                                                    <td height="25" align="center" valign="middle" bgcolor="#C5D5E4"><strong>书名</strong></td>
                                        <td width="21%" align="center" valign="middle" bgcolor="#C5D5E4"><strong>类别</strong></td>
                                        <td width="17%"  height="25" align="center" valign="middle" bgcolor="#C5D5E4"><strong>作者</strong></td>
                      <td width="17%"  height="25" align="center" valign="middle" bgcolor="#C5D5E4"><strong>出版社</strong></td>
                      <td width="14%" height="25" align="center" valign="middle" bgcolor="#C5D5E4"><strong>出版时间</strong></td>
                      <td width="9%" align="center" valign="middle" bgcolor="#C5D5E4" ><strong>查看</strong></td>
</tr>
                                                  <%
			For i=1 To x
			%>
                                                  <tr>
                                                    <td height="25"  align="center" valign="middle" bgcolor="#C5D5E4"><a href="show.asp?id=<%=rs("id")%>" class="d" target="_self"><%=rs("b_NAME")%></a></td>
                                                    <td align="center" valign="middle" bgcolor="#C5D5E4"><% id=rs("b_sort")
													response.Write(conn.execute("select id,name from lb where id="&id)("name"))%></td>
                                                    <td  height="25" align="center" valign="middle" bgcolor="#C5D5E4"><%=rs("b_WRITER")%></td>
                                                    <td height="25" align="center" valign="middle" bgcolor="#C5D5E4"><%=rs("b_CONCERN")%></td>
                                                    <td  height="25" align="center" valign="middle" bgcolor="#C5D5E4"><%=rs("b_DATE")%></td>
                                                    <td align="center" valign="middle" bgcolor="#C5D5E4"><a href="show.asp?id=<%=rs("id")%>" class="d" target="_self">查看</a></td>
                                  </tr>
                                                  <%
			rs.movenext
		    next
			%>
                                              </table>
                                            <%
		call PageControl(iCount,maxpage,page,"border=0 align=center","<p align=center>")
		end if
		rs.close
		set rs=nothing
Sub PageControl(iCount,pagecount,page,table_style,font_style)
    Dim query, a, x, temp
    action = "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME")
    query = Split(Request.ServerVariables("QUERY_STRING"), "&")
    For Each x In query
        a = Split(x, "=")
        If StrComp(a(0), "page", vbTextCompare) <> 0 Then
            temp = temp & a(0) & "=" & a(1) & "&"
        End If
    Next
    Response.Write("<table width=90% border=0 cellpadding=0 cellspacing=0  align=center >" & vbCrLf )        
    Response.Write("<form method=get onsubmit=""document.location = '" & action & "?" & temp & "Page='+ this.page.value;return false;""><TR>" & vbCrLf )
    Response.Write("<TD align=center height=35>" & vbCrLf )
    Response.Write(font_style & vbCrLf )    
    if page<=1 then
        Response.Write ("首页 " & vbCrLf)        
        Response.Write ("上页 " & vbCrLf)
    else        
        Response.Write("<A HREF=" & action & "?" & temp & "Page=1>首页</A> " & vbCrLf)
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page-1) & ">上页</A> " & vbCrLf)
    end if
    if page>=pagecount then
        Response.Write ("下页 " & vbCrLf)
        Response.Write ("尾页 " & vbCrLf)            
    else
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & (Page+1) & ">下页</A> " & vbCrLf)
        Response.Write("<A HREF=" & action & "?" & temp & "Page=" & pagecount & ">尾页</A> " & vbCrLf)            
    end if
    Response.Write(" 页次:" & page & "/" & pageCount & "页" &  vbCrLf)
    Response.Write(" 共有" & iCount & "条" &  vbCrLf)
    Response.Write(" 转到" & "<INPUT TYEP=TEXT NAME=page SIZE=2 Maxlength=5 VALUE=" & page & ">" & "页"  & vbCrLf & "<INPUT type=submit value=GO>")
    Response.Write("</TD>" & vbCrLf )                
    Response.Write("</TR>" & vbCrLf )        
    Response.Write("</table>" & vbCrLf )        
End Sub
%>                                            </td>
                                          </tr>
                                    </table></td>
                                  </tr>
                              </table></td>
  </tr>
                          <tr></tr>
</table></td>
  </tr>
  <tr>
    <td height="60"><!--#include file="bottom.asp"--></td>
  </tr>
</table>
</center>
</form>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?