按键二;根据条件查询后显示结果

Posted can丶

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了按键二;根据条件查询后显示结果相关的知识,希望对你有一定的参考价值。

<%@ page language="java" import="java.util.*" import="java.sql.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP ‘find_stu_3.jsp‘ starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>
<head><title>由提交页面获取查询条件并实现查询的页面</title></head>
<body><center>
<% String driverName="com.mysql.jdbc.Driver";
String dbName="MyLogin";
String userName="root";
String userPwd="lovezjl";
String url1="jdbc:mysql://localhost:3306/MyLogin";
String url2="?user=root&password=lovezjl";
String url3="&useUnicode=true&characterEncoding=UTF-8";
String url=url1+url2+url3;
Class.forName(driverName);
Connection conn=DriverManager.getConnection(url);

request.setCharacterEncoding("UTF-8");
String sex1=request.getParameter("s1");
String sushe1=(request.getParameter("s2"));
String sql="select * from student_xinxi1 where sex=? and sushe=?";
PreparedStatement pstmt=conn.prepareStatement(sql);
pstmt.setString(1,sex1);
pstmt.setString(2,sushe1);


ResultSet rs=pstmt.executeQuery();
rs.last();%>
<font size="5" color ="red"><%=rs.getRow()%></font>条信息
<table border="2" bgcolor="cceeec" width="650">
<tr bgcolor="CCCCCC" align="center">
<td>记录条数</td><td>宿舍号</td><td>订水数量</td><td>是否接单</td><td>送单状态</td>
</tr>
<%rs.beforeFirst();
while(rs.next()){
%> <tr align="center">
<td><%=rs.getRow() %></td>
<td><%=rs.getString("sushe") %></td>
<td><%=rs.getString("shuliang") %></td>
<td><%=rs.getString("jiedan") %></td>
<td><%=rs.getString("song") %></td>
</tr>
<%} %>
</table>
</center>
<%if(rs!=null){rs.close();}
if(pstmt!=null){pstmt.close();}
if(conn!=null){conn.close();} %>

<style type="text/css">
body{
background:url("image/444.jpg");
background-size:100%;
}

</center> </body>
</html>

以上是关于按键二;根据条件查询后显示结果的主要内容,如果未能解决你的问题,请参考以下文章

MySql操作「数据查询条件20211223

朋友,您好,我想问Django分页后查询条件丢失的问题

如何根据where条件值创建mysql查询结果?

对sql语句的查询结果按条件显示不同的颜色

查询多个结果是用case when 条件显示列的查询效率高,还是查询后union all合并效率高.

对sql语句的查询结果按条件显示不同的颜色