📄 resultadvance1.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.util.*" %>
<!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">
<STYLE type=text/css>BODY {
FONT-SIZE: 13px; FONT-FAMILY: 宋体; TEXT-ALIGN: center
}
TR {
FONT-SIZE: 13px; FONT-FAMILY: 宋体; TEXT-ALIGN: center
}
TD {
FONT-SIZE: 13px; FONT-FAMILY: 宋体; TEXT-ALIGN: center
}
</STYLE>
<META content="MSHTML 6.00.2900.2995" name=GENERATOR><title>高级查询结果</title></HEAD>
<BODY>
<%
Connection con;
String statement="";
String statement1="";
ResultSet result,result1;
int count=0;
String all_station[]=new String[2000]; //用来存放所有站点(不重复)
String stations[]=new String[200];//存放某一路车的所有站点
int countbus=0;//计算某一路车的站点数
String station1="";
String station2="";
int flag=0,mark=0;
String relation[]=new String[200];
int countrelation=0; //计算与关键字相关的站点个数
String keywords[]=new String[10];//存储关键字按空格分段的子关键字
int countkeyword=0;//计算子关键字的个数
String busid="";
String detail="";
String a_startime="";
String a_endtime="";
String w_startime="";
String w_endtime="";
int t_value=0;
String keyword=new String(request.getParameter("advance1").getBytes("ISO8859_1"),"GBK");
String method=new String(request.getParameter("select").getBytes("ISO8859_1"),"GBK");
try{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
try{
con=DriverManager.getConnection("jdbc:odbc:nbos","","");
if(method.equals("按站点查询"))//按站点查询
{ Statement sql=con.createStatement();
statement="select * from bus";
result=sql.executeQuery(statement);
if(result.next())
{ detail=result.getString("Detail");
// out.println(detail);
StringTokenizer str=new StringTokenizer(detail,"->");
while(str.hasMoreTokens())
{ all_station[count]=str.nextToken();
count++;
}//endwhile
}//endif
while(result.next())
{ detail=result.getString("Detail");
//out.println(detail);
StringTokenizer str1=new StringTokenizer(detail,"->");
while(str1.hasMoreTokens())
{ mark=0;
station2=str1.nextToken();
//out.println(station2);
for(int k=0;k<count&&mark==0;k++)
{
if(station2.indexOf(all_station[k])!=-1||all_station[k].indexOf(station2)!=-1)
{ mark=1;
flag=0;
}
else
flag=1;
} //for
if(flag==1)
{ all_station[count]=station2;
count++;
}//endif
} //endwhile
} //endwhile
for(int i=0;i<count;i++)
{ if(all_station[i].indexOf(keyword)!=-1)
{ relation[countrelation]=all_station[i];
countrelation++;
}//endif
}//endfor
result.close();
if(countrelation>0)
{ %><TABLE cellSpacing=1 cellPadding=3 width=650 align=center bgColor=#003399
border=0>
<TBODY>
<TR>
<TD background=Picture/topbg.gif height=20></TD>
</TR>
<TR bgColor=#7da4ec>
<TD><STRONG><FONT color=#ffffff>
高级查询一结果(按站点查询)</FONT></STRONG></TD>
</TR>
<TR bgColor=#e8f3ff>
<TD><!--查询结果显示开始-->
<TABLE cellSpacing=1 cellPadding=3 width=500 bgColor=#003399 border=0>
<TBODY>
<TR bgColor=#fddd90>
<TD width=150>关键字:
<font color="#FF0000"><%=keyword%></font></TD>
<TD>共有<font color="#FF0000"><%=countrelation%></font>个相关站点</TD>
</TR>
<TR bgColor=#fddd90>
<TD width=150>站点编号</TD>
<TD>相关站点</TD>
</TR>
<% for(int n=0;n<countrelation;n++) { %>
<TR onmouseover="this.style.backgroundColor = '#FFF9EE'"
onmouseout="this.style.backgroundColor = ''" bgColor=#e8f3ff>
<TD><%=n+1%></TD>
<TD><a href="resultquery2.jsp?query2=<%=relation[n]%>" target="_blank"><%=relation[n]%></a></TD>
</TR>
<% }//endfor
%>
</TBODY></TABLE>
<!--查询结果显示结束--><BR> <IMG
src="Picture/close_window.gif" width="78" height="21" border=0
style="CURSOR: hand" onclick=window.close()> </TD>
</TR>
<TR>
<TD background=Picture/bottombg.gif
height=20></TD>
</TR></TBODY></TABLE>
<% }//endif(relationcount>0)
else //relationcount<0
{ %>
<TABLE cellSpacing=1 cellPadding=3 width=650 align=center bgColor=#003399
border=0>
<TBODY>
<TR>
<TD background=Picture/topbg.gif height=20></TD>
</TR>
<TR bgColor=#7da4ec>
<TD><STRONG><FONT color=#ffffff> 高级查询一结果(按站点查询)</FONT></STRONG></TD>
</TR>
<TR bgColor=#e8f3ff>
<TD><!--查询结果显示开始-->
<TABLE cellSpacing=1 cellPadding=3 width=500 bgColor=#003399 border=0>
<TBODY>
<TR bgColor=#fddd90>
<TD colspan="2">对不起!暂无关键字为<font color="#FF0000"><%=keyword%></font>的相关站点!请试用其他查询方式!</TD>
</TR>
</TBODY>
</TABLE>
<!--查询结果显示结束-->
<BR>
<IMG
src="Picture/close_window.gif" width="78" height="21" border=0
style="CURSOR: hand" onclick=window.close()> </TD>
</TR>
<TR>
<TD background=Picture/bottombg.gif
height=20></TD>
</TR>
</TBODY>
</TABLE>
<% }//endelse
} //endif按站点查询
else if(method.equals("按路线查询")) //按车次查询
{
Statement sql1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
StringTokenizer str2=new StringTokenizer(keyword," ");
while(str2.hasMoreTokens())
{ keywords[countkeyword]=str2.nextToken();
countkeyword++;
}
//out.println(countkeyword);
statement1="select * from bus where Detail LIKE '%"+keywords[0]+"%'";
for(int h=1;h<countkeyword;h++)
{ statement1=statement1+"AND Detail LIKE '%"+keywords[h]+"%'";
//out.println("第"+h+"次");
}
statement1=statement1+"ORDER BY Sort ASC";
// out.print(statement1);
result1=sql1.executeQuery(statement1);
if(!result1.next())
{ // out.println("b");%>
<TABLE cellSpacing=1 cellPadding=3 width=650 align=center bgColor=#003399
border=0>
<TBODY>
<TR>
<TD background=Picture/topbg.gif height=20></TD>
</TR>
<TR bgColor=#7da4ec>
<TD><STRONG><FONT color=#ffffff> 高级查询一结果(按车次查询)</FONT></STRONG></TD>
</TR>
<TR bgColor=#e8f3ff>
<TD><!--查询结果显示开始-->
<TABLE cellSpacing=1 cellPadding=3 width=500 bgColor=#003399 border=0>
<TBODY>
<TR bgColor=#fddd90>
<TD colspan="2">对不起!暂无关键字为<font color="#FF0000"><%=keyword%></font>的相关车次!请试用其他查询方式!</TD>
</TR>
</TBODY>
</TABLE>
<!--查询结果显示结束-->
<BR>
<IMG
src="Picture/close_window.gif" width="78" height="21" border=0
style="CURSOR: hand" onclick=window.close()> </TD>
</TR>
<TR>
<TD background=Picture/bottombg.gif
height=20></TD>
</TR>
</TBODY>
</TABLE>
<% } //endif没有找到结果集
else
{
result1.previous();
%>
<TABLE cellSpacing=1 cellPadding=3 width=650 align=center bgColor=#003399
border=0>
<TBODY>
<TR>
<TD background=Picture/topbg.gif height=20></TD>
</TR>
<TR bgColor=#7da4ec>
<TD><STRONG><FONT color=#ffffff>高级查询一结果(按车次查询)</FONT></STRONG></TD>
</TR>
<TR bgColor=#e8f3ff>
<TD><!--查询结果显示开始-->
<TABLE width=500 height="72" border=0 cellPadding=3 cellSpacing=1 bgColor=#003399>
<TBODY>
<TR bgColor=#fddd90>
<TD height="19" colspan="2">以下是与关键字<font color="#FF0000"><%=keyword%></font>相关的车次及详细信息<STRONG><font color="#FF0000"></font></STRONG></TD>
</TR>
<TR bgColor=#fddd90>
<TD width=73 height="19">车次号</TD>
<TD width="412">经过的所有站点</TD>
</TR>
<%
//循环地把满足关键字的车次输出
while(result1.next())
{ busid=result1.getString("BusID");
detail=result1.getString("Detail");
StringTokenizer str3=new StringTokenizer(detail,"->");
countbus=0;
while(str3.hasMoreTokens())
{ stations[countbus]=str3.nextToken();
countbus++;
}//endwhile
%>
<TR onmouseover="this.style.backgroundColor = '#FFF9EE'"
onmouseout="this.style.backgroundColor = ''" bgColor=#e8f3ff>
<TD><a href="resultquery1.jsp?query1=<%=busid%>" target="_blank"><%=busid%></a></TD>
<TD> <div align="left">
<%
//按某种格式输出所有站点
for(int k=0;k<countbus;k++)
{ if(countkeyword>1)
{ if(stations[k].indexOf(keywords[0])!=-1)
{ //按红色输出
%>
<font color="#FF0000"><%=stations[k]%> </font>
<%
}
else if(stations[k].indexOf(keywords[1])!=-1)
{ //按蓝色输出
%>
<font color="#0000FF"><%=stations[k]%> </font>
<%
}
else
{ %>
<font size="2"><%=stations[k]%> </font>
<% }
}
else
{
if(stations[k].indexOf(keywords[0])!=-1)
{ //按红色显示
%>
<font color="#FF0000"><%=stations[k]%> </font>
<%
}//endif
else { %>
<font size="2"><%=stations[k]%> </font>
<% }//endelse
} //endelse
}//endfor
%>
</div></TD>
</TR>
<% }//end while
result1.close();
%>
</TBODY>
</TABLE>
<!--查询结果显示结束-->
<BR>
<IMG
src="Picture/close_window.gif" width="78" height="21" border=0
style="CURSOR: hand" onclick=window.close()> </TD>
</TR>
<TR>
<TD background=Picture/bottombg.gif
height=20></TD>
</TR>
</TBODY>
</TABLE>
<p>
<%
} //endelse有结果集
// out.println("sdafsda");
}//endelse按车次查询
else//按车次查询
{ int id=Integer.parseInt(keyword);
Statement sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
statement="select * from bus where Sort="+id+"";
result=sql.executeQuery(statement);
if(!result.next())
{ response.sendRedirect("errorquery1.jsp");
}
else
{ result.previous();
//显示站点的详细信息
while(result.next()){
String Detail=result.getString("Detail");
a_startime=result.getString("A_STime");
a_endtime=result.getString("A_ETime");
w_startime=result.getString("W_STime");
w_endtime=result.getString("W_ETime");
t_value=result.getInt("T_Value");
StringTokenizer str1=new StringTokenizer(Detail,"->");
while(str1.hasMoreTokens())
{ stations[count]=str1.nextToken();
count++;
}//endwhile
}//endelse
}//endtry
result.close();
%>
</p>
<TABLE cellSpacing=1 cellPadding=3 width=650 align=center bgColor=#003399
border=0>
<TBODY>
<TR>
<TD background=Picture/topbg.gif height=20></TD>
</TR>
<TR bgColor=#7da4ec>
<TD><STRONG><FONT color=#ffffff> 车次查询结果</FONT></STRONG></TD>
</TR>
<TR bgColor=#e8f3ff>
<TD><!--查询结果显示开始-->
<TABLE cellSpacing=1 cellPadding=3 width=500 bgColor=#003399 border=0>
<TBODY>
<TR bgColor=#fddd90>
<TD width=150 rowspan="2">车次: <font color="#FF0000"><%=keyword%></font> 路车</TD>
<TD width="87" rowspan="2">票价:<font color="#FF0000"><%=t_value%></font>元</TD>
<TD width="241">夏季时间:<%=a_startime%>--<%=a_endtime%></TD>
</TR>
<TR bgColor=#fddd90>
<TD>冬季时间:<%=w_startime%>--<%=w_endtime%></TD>
</TR>
<TR bgColor=#fddd90>
<TD width=150>经过站次</TD>
<TD colspan="2">经过站点</TD>
</TR>
<% for(int i=0;i<count;i++) { %>
<TR onmouseover="this.style.backgroundColor = '#FFF9EE'"
onmouseout="this.style.backgroundColor = ''" bgColor=#e8f3ff>
<TD><%=i+1%></TD>
<TD colspan="2"><a href="resultquery2.jsp?query2=<%=stations[i]%>" target="_blank"><%=stations[i]%></a></TD>
</TR>
<% } %>
</TBODY>
</TABLE>
<!--查询结果显示结束-->
<BR>
<IMG
src="Picture/close_window.gif" width="78" height="21" border=0
style="CURSOR: hand" onclick=window.close()> </TD>
</TR>
<TR>
<TD background=Picture/bottombg.gif
height=20></TD>
</TR>
</TBODY>
</TABLE>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</BODY>
<% } //end按车次查询
}//endtry
catch(SQLException e1){}
%></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -