81,116
社区成员
发帖
与我相关
我的任务
分享
<table width="100%" border="0">
<tr>
<td height="20" valign="middle" bgcolor="#FFFFFF"><form id="form" name="form" method="post" action="query.jsp">
<p><span class="STYLE24"> 图书搜索</span>
<select name="select" size="1" id="select">
<option selected="selected">书名</option>
<option>作者</option>
<option >出版社</option>
<option>ISBN</option>
</select>
<input name="textinput" type="text" id="textinput" size="60" />
<span class="STYLE21"><a href="javascript:check()" ><img src="img/zongyemian/Button_sousuo.gif" width="72" height="22" /></a> <a href="#"><strong>高级搜索</strong></a></span> </p>
</form> </td>
</tr>
</table><%@ page contentType="text/html" pageEncoding="GB2312"%>
<%@ include file="datainit.jsp" %>
<html>
<body>
<%!
public String formatStr(String str){
return str==null?"":str;
}
%>
<%
String selected=formatStr(request.getParameter("select"));
String textinput=formatStr(request.getParameter("textinput"));
String strSql="";
if(textinput.equals("书名")){
strSql="select * from Book where BookName = '"+selected+"'";
}else if(textinput.equals("作者")){
strSql="select * from Book where Writer = '"+selected+"'";
}else if(textinput.equals("出版社")){
strSql="select * from Book where Publisher = '"+selected+"'";
}else{
strSql="select * from Book where BookID = '"+selected+"'";
}
%>
<%
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(strSql);
while(rs.next()){
out.print("<html><body>你查询的结果为:");
out.print(rs.getString(1));
out.print(rs.getString(2));
out.print("</body></html>");
}
out.print("没有您要找的书");
out.print(selected);
%>
</body></html> <%@ page contentType="text/html;charset=GBK" pageEncoding="GBK"%> <%@ page contentType="text/html" pageEncoding="GB2312"%>
<%request.setCharacterEncoding("GBK");%>
<%@ include file="datainit.jsp" %>