⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 select.jsp

📁 WEB图书馆系统,jsp编写,适用用于JSP的初始者
💻 JSP
字号:
<%@ page contentType="text/html;charset=GB2312"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.lang.Exception.*"%>
<%
//数据库连接
String url="jdbc:odbc:xuesheng";
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
  Connection con=DriverManager.getConnection(url);
  Statement stmt=con.createStatement();
  ResultSet result=stmt.executeQuery("select * from xinxi_book");
  ResultSetMetaData resultmd=result.getMetaData();
%>
<html>
<head>
   <title>查询信息</title>
<style type="text/css">
<!--
body {
	background-image: url(684514.jpg);
}
}
-->
</style>
</head>

<center>
&nbsp;&nbsp;&nbsp;<h2>请输入查询的信息<h>
<form method="POST" action="select.jsp">

<p>
<select size="1" name="rowname">
   
   <option>book_name</option>
   <option>book_author</option>
</select>

<select type="text" name="compare">
<option>=</option>
</select>

<input type="text" name="condition">
<input type="submit" value="提交">
<font face="方正舒体" size="4"><A  href="index2.jsp" >返回上页</font></A>
</form>
</p>
<p>

</p>
<p>
<%
if(request.getParameter("rowname")!=null)
{
    String rowname=request.getParameter("rowname");
    String compare=request.getParameter("compare");
    String condition=request.getParameter("condition"); 
%>

<table border="1">

<%
int count=resultmd.getColumnCount();
out.print("<td>图书编号</td>"); 
out.print("<td>图书名称</td>"); 
out.print("<td>图书作者</td>"); 
out.print("<td>图书价格</td>"); 
out.print("<td>图书数量</td>"); 
condition = new String(condition.getBytes("ISO-8859-1"), "GBK"); 
String sql="select * from xinxi_book where "+rowname+ compare+"'"+condition+"'";
ResultSet result1=stmt.executeQuery(sql);
//out.println(sql);
out.println("<br>");
while(result1.next())
  {
    out.println("<tr>");
	  out.println("<td>"+result1.getString(1)+"</td>");
	  out.println("<td>"+result1.getString(2)+"</td>");
	  out.println("<td>"+result1.getString(3)+"</td>");
	  out.println("<td>"+result1.getString(4)+"</td>");
	  out.println("<td>"+result1.getString(5)+"</td>");
    out.println("</tr>");
  }
%>
</table>
</center>
<%
stmt.close();
con.close();
}
%>
</p>
<body>
<center>
<p>
注:
</p>
<p>
<h3>book_name为书名</h>
</p>
<p>
<h3>book_author为作者</h>
</p>
</body>
</html>



⌨️ 快捷键说明

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