📄 searchbook_post.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="../ch.jsp" %>
<%@ include file="checkadmin.jsp"%>
<jsp:useBean id="search" class="conndb.DbConnBean" scope="request" />
<%
String sql="";
String keyword=request.getParameter("keyword");
String tkeyword=search.chStr(keyword);//解决中文乱码
String keytype=request.getParameter("type");
if(keytype.equals("booktitle")){sql="select * from book where title like '%"+tkeyword+"%'";}
else if(keytype.equals("bookid")){sql="select * from book where bookID like '%"+tkeyword+"%'";}
int temp=search.select(sql);
Connection conn=search.getConn();
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
String color="#CCCCCC";
int id=0;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>图书查询结果</title>
</head>
<body>
<div align="center">
<% if(temp==0){out.println("对不起,没有查到相关图书,请<a style=cursor:hand onclick=javascript:history.back();><b>重新查找</b></a>.");}else{ %>
<strong>图书查询结果</strong></div>
<table width="72%" border="0" align="center">
<tr bgcolor="00CCFF" >
<td>序号</td><td>书名</td><td>图书编号</td><td>分类</td><td>库存量</td>
</tr>
<%
while(rs.next()){
String booktitle=rs.getString(2);
String bookid=rs.getString(3);
String booktype=rs.getString(4);
int quantity=rs.getInt(5);
id++;
if(color=="#CCCCCC"){color="#999999";}
else{color="#CCCCCC";}
%>
<tr bgcolor=<%=color%>>
<td><%=id%></td><td><%=booktitle%></td><td><%=bookid%></td><td><%=booktype%></td><td><%=quantity%></td>
</tr>
<%}}%>
</table><br><center>当前库中一共有相关图书<%= id %>种</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -