orderSearch.jsp<script language="JavaScript">function RgTest() {
if(document.order.orderId.value=="") {
window.alert("请输入查询订单号!");
document.order.orderId.focus();
return false;
}
return true;
}
</script>
<body>
<%@ include file="adminlink.jsp" %>
<center>
<h1 class="STYLE1">订单查询</h1>
<form action="orderSearch.jsp" method="post" name="orderId">
<table border="1" bgcolor="#286D52">
<tr><td width="120px" align="right">请输入订单号:</td><td align="left" width="300px"><input type="text" name="orderId"><input type="submit" value="查询" onClick="return RgTest()"/></td></tr>
</table>
<%@ include file="orderSearchResult.jsp"%>
</form>orderSearchResult.jsp
<jsp:useBean id="dataConnection" scope="page" class="org.me.dataConnection">
</jsp:useBean>
<body>
<%
String orderId=request.getParameter("orderId");
Connection con=dataConnection.getConnection();
try{
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from form where orderId='"+orderId+"'");
if(rs.next()){
String userId=trans(rs.getString("userId"));
String userName=trans(rs.getString("userName"));
String carId=trans(rs.getString("carId"));
String carType=trans(rs.getString("carType"));
java.sql.Date start=rs.getDate("start");
java.sql.Date end=rs.getDate("end");
String from=trans(rs.getString("from"));
String to=trans(rs.getString("to"));
int fare=rs.getInt("fare");
String order=trans(rs.getString("order"));
String telephone=trans(rs.getString("telephone"));
%>
<center>我想问下如果我要根据start(开始日期)来查询订单呢?这个怎么写了???
if(document.order.orderId.value=="") {
window.alert("请输入查询订单号!");
document.order.orderId.focus();
return false;
}
return true;
}
</script>
<body>
<%@ include file="adminlink.jsp" %>
<center>
<h1 class="STYLE1">订单查询</h1>
<form action="orderSearch.jsp" method="post" name="orderId">
<table border="1" bgcolor="#286D52">
<tr><td width="120px" align="right">请输入订单号:</td><td align="left" width="300px"><input type="text" name="orderId"><input type="submit" value="查询" onClick="return RgTest()"/></td></tr>
</table>
<%@ include file="orderSearchResult.jsp"%>
</form>orderSearchResult.jsp
<jsp:useBean id="dataConnection" scope="page" class="org.me.dataConnection">
</jsp:useBean>
<body>
<%
String orderId=request.getParameter("orderId");
Connection con=dataConnection.getConnection();
try{
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from form where orderId='"+orderId+"'");
if(rs.next()){
String userId=trans(rs.getString("userId"));
String userName=trans(rs.getString("userName"));
String carId=trans(rs.getString("carId"));
String carType=trans(rs.getString("carType"));
java.sql.Date start=rs.getDate("start");
java.sql.Date end=rs.getDate("end");
String from=trans(rs.getString("from"));
String to=trans(rs.getString("to"));
int fare=rs.getInt("fare");
String order=trans(rs.getString("order"));
String telephone=trans(rs.getString("telephone"));
%>
<center>我想问下如果我要根据start(开始日期)来查询订单呢?这个怎么写了???
不行吗?
无非就是再给用户一个选择(开始日期)的输入框吧,跟orderID的取法一样啊
(
d datetime
)
goinsert into t values('2000-1-1');
insert into t values('2001-1-1');
insert into t values('2002-1-1');select * from t;
select * from t where d = '2000-1-1';--------------------
(所影响的行数为 1 行)
(所影响的行数为 1 行)
(所影响的行数为 1 行)d
------------------------------------------------------
2000-01-01 00:00:00.000
2001-01-01 00:00:00.000
2002-01-01 00:00:00.000(所影响的行数为 3 行)d
------------------------------------------------------
2000-01-01 00:00:00.000(所影响的行数为 1 行)
或者就用sql的函数来处理你的字符串,转成日期类型来用