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

📄 search.jsp

📁 JSP数据库编程指南GOOD JSP行前准备JSP由浅入深JSP高级编程构建安全的ASP.NET应用(CHM) 即时即用ASP脚本第二版
💻 JSP
字号:

<%@ include file="header.inc"%>  
<%@ page language="java" import="java.sql.*" %>
	<jsp:useBean id="workM" scope="page" class="test.faq" />

<jsp:useBean id='clock' scope='page' class='dates.JspCalendar' type="dates.JspCalendar" />      
<%!
public String getStr(String str)
{
	try
	{
		String temp_p=str;
		byte[] temp_t=temp_p.getBytes("GBK");
		String temp=new String(temp_t,"ISO8859_1");
		return temp;
	}
	catch(Exception e)
	{
	 
	}
	return "null";
}
%>                        
<TABLE border=0 cellPadding=0 cellSpacing=0 width=760 align="center">
  <TBODY>
  <tr><td align="left" height=25>当前位置:<a href="../index.jsp">首页</a> -&gt; 教程文章  </td>
 <%@ include file="date.inc"%>
  </tr>
  <TR bgColor=#3399ff>
    <TD height=1 colspan="2"><IMG height=1 src="images/spacer.gif" 
  width=16></TD></TR>
  <tr><td height=10 colspan="2"><IMG height=1 src="images/spacer.gif" 
  width=16></td></tr>
  </TBODY></TABLE>

  <table align="center" border="0" width="760" cellspacing="0" cellpadding="0" height="355">                  
	<tr>                  
		<td width="150" height="355" valign="top">                  
						<%///******************%>
<%@ include file="table.inc"%>
	<%//////********************%>                  
	                
		</td>                  
		<td width="10" height="100%"></td>
		<td width="1" height="100%" bgcolor="#3399ff"></td>
		<td width="10" height="100%"></td>
		<td width="589" height="331" valign="top" background="images/bg1.gif">                       
        <table border="0" width="100%" cellspacing="0" cellpadding="0">                  
          <tr>                  
            <td colspan="3" width="100%" height="20" bgcolor="#3399ff">&nbsp;<font color="#ffffff">站内搜索 -> 关键字:<b><font color="Red"><%=request.getParameter("keyword")%></font></b></font>
			</td>
		  </tr>
		  <tr>
		 
		  <td align="center" colspan='3' valign="top">


	<%
		String keyword,bankuai,searchT,searchC;
		String strSQL;
		keyword=request.getParameter("keyword");
		bankuai=request.getParameter("bankuai");
		searchT=request.getParameter("t");
		searchC=request.getParameter("c");
		strSQL="";

	    boolean srchT,srchC,srchTC,nosrchT,nosrchC;
		srchT=(searchT!=null);
		srchC=(searchC!=null);
		nosrchT=(searchT==null);
		nosrchC=(searchC==null);
		srchTC=(srchT&&srchC);
		
		//out.println(srchT&&nosrchC);
		//out.println(srchC&&nosrchT);
		//out.println(srchTC);
		//////////////教程文章********************
		if(bankuai.trim().equals("2")){
			strSQL="SELECT * FROM article where";
			//////////按标题 
			if(srchT&&nosrchC){
				strSQL=strSQL+" title like '%"+keyword+"%'";
			}
			//////////按内容 
			if(srchC&&nosrchT){
				strSQL=strSQL+" content like '%"+keyword+"%'";
			}
			//////////按内容&&&&按标题
			if(srchTC){
				strSQL=strSQL+" title like '%"+keyword+"%' or  content like '%"+keyword+"%'";
			}
		}
		
		//////////////常见问题********************
		if(bankuai.trim().equals("7")){
			strSQL="SELECT * FROM faqs where";
			//////////按标题 
			if(srchT&&nosrchC){
				strSQL=strSQL+" Subject like '%"+keyword+"%'";
			}
			//////////按内容 
			if(srchC&&nosrchT){
				strSQL=strSQL+" Answer like '%"+keyword+"%'";
			}
			//////////按内容&&&&按标题
			if(srchTC){
				strSQL=strSQL+" Answer like '%"+keyword+"%' or Subject like '%"+keyword+"%'";
			}
		}
		
		//////////////全部资料********************
		if(bankuai.trim().equals("99")){
			strSQL="SELECT * FROM article,faqs where";
			//////////按标题 
			if(srchT&&nosrchC){
				strSQL=strSQL+" faqs.Subject like '%"+keyword+"%'"+" or article.title like '%"+keyword+"%'";
			}
			//////////按内容 
			if(srchC&&nosrchT){
				strSQL=strSQL+" faqs.Answer like '%"+keyword+"%'"+" or article.content like '%"+keyword+"%'";			}
			//////////按内容&&&&按标题
			if(srchTC){
				strSQL=strSQL+" faqs.Answer like '%"+keyword+"%' or faqs.Subject like '%"+keyword+"%'";
				strSQL=strSQL+" or article.title like '%"+keyword+"%'"+" or article.content like '%"+keyword+"%'";
			}
		}
		//out.println(strSQL);

		out.println("<ul>");
		ResultSet RSa = workM.executeQuery(strSQL);
		int searchnum;
		searchnum=0;
		while (RSa.next()) {
			String srch_title;
			srch_title=getStr(RSa.getString("title"));
			out.println("<li>"+srch_title);
			searchnum=searchnum+1;
		}
		RSa.close();
		out.println("</ul>");
  		out.println("共搜索到<b><font color=Red>"+searchnum+"</font></b>条纪录");
	%>
	<form name='form1' method='post'>
	<input type='hidden' name='id' value='216'>
	<input type='hidden' name='bankuai' value='2'>
	<input type='hidden' name='CZ' value='emailtome'></form>
	
		<p align="right"><a href="javascript:history.go(-1)">返 回</a></p>


			<script language="javascript">
			function sub_back()
			{
				self.location="index.php";
			}
			function emailtome(id)
			{
				document.form1.submit();
			}
			</script>

			</td>
			 <td width="5%"></td>
		  </tr>
        </table>                  

        </td>
    </tr>
  </table>
<%@ include file="footer.inc"%>

⌨️ 快捷键说明

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