<!--#include file="conn.asp"-->
<%
Set rs = Server.CreateObject("ADODB.Recordset")
name=trim(request("keyword"))
if name="" then
	response.write "<SCRIPT language=JavaScript>alert('查找字符不能为空!');"
	response.write "this.location.href='vbscript:history.back()';</SCRIPT>"
	response.end
end if

sql="select * from data WHERE question Like '%"& name &"%' or key Like '%"& name &"%' order by id desc"
rs.open sql,conn,1,1

if rs.eof then
	response.write "<SCRIPT language=JavaScript>alert('对不起，没有找到您要找的题目！');"
	response.write "this.location.href='vbscript:history.back()';</SCRIPT>"
   	response.end
else
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>六娱中文网-脑筋急转弯 - 搜索结果</title>
<style type="text/css">
<!-- 
td           { font-size: 12px; line-height: 17px }
body         { font-size: 12px; line-height: 17px }
p            { margin-top: 1px; margin-bottom: 1px }
a:link       { text-decoration: none; color: black }
a:visited    { text-decoration: none; color: black }
a:active     { text-decoration: none }
a:hover      { text-decoration: underline; color: red }
body,p,td    { font-family:Verdana, Arial, Helvetica, sans-serif; }
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_popupMsg(msg) { //v1.0
  alert(msg);
}
//-->
</script>
</head>

<body background="images/bg.gif">
<!--#include file="head.asp"-->
<div align="center">
  <center>
  <table border="1" width="870" bordercolorlight="#3399FF" cellspacing="0" cellpadding="0" bordercolordark="#FFFFFF" bgcolor="#ECF5FF">
    <tr>
      <td width="100%" height="25">
        <p align="center">您输入的关键字是：<font color="red"><%=name%></font>&nbsp;  
        以下是搜索结果：</p> 
      </td> 
    </tr> 
  </table> 
  </center> 
</div> 
<div align="center"> 
  <center> 
  <table width="870" border="1" cellpadding="0" cellspacing="0" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"> 
    <tr> 
      <td width="57" height="25" bgcolor="#BBDBFF" align="center"><img border="0" src="images/num.gif"></td> 
      <td width="536" height="25" bgcolor="#BBDBFF" align="center"><img border="0" src="images/question.gif"></td> 
      <td width="95" height="25" bgcolor="#BBDBFF" align="center"><img border="0" src="images/key.gif"></td> 
    </tr> 
<%                        
const maxperpage=100               
dim currentpage               
rs.pagesize=maxperpage               
currentpage=request.querystring("pageid")               
if currentpage="" then               
currentpage=1               
elseif currentpage<1 then               
currentpage=1               
else               
currentpage=clng(currentpage)               
	if currentpage > rs.pagecount then               
	currentpage=rs.pagecount               
	end if               
end if               
               
if not isnumeric(currentpage) then               
currentpage=1               
end if               
dim totalput,n               
totalput=rs.recordcount               
if totalput mod maxperpage=0 then               
n=totalput\maxperpage               
else               
n=totalput\maxperpage+1               
end if               
if n=0 then               
n=1               
end if               
rs.move(currentpage-1)*maxperpage               
i=0      
w=1          
do while i< maxperpage and not rs.eof   
red_name = replace(rs("question"),name,"<font color=#ff0000>"&name&"</font>")          
%> 
    <tr> 
      <td width="57" bgcolor="#ECF5FF"> 
        <p align="center"><font color="#800000"><%=w%></font></p> 
      </td> 
      <td width="539" bgcolor="#ECF5FF">&nbsp;<font color="#008080"><%=red_name%></font>     
      <%if session("admin")<>"" then%>                                                                           
    &nbsp;<a href="edit.asp?id=<%=rs("id")%>"><font color="#008000">编辑</font></a>&nbsp;<a href="del.asp?id=<%=rs("id")%>"><font color="red">删除</font></a>      
        <%end if%>      
      </td>      
      <td width="95" bgcolor="#ECF5FF">   
      <p align="center">  
      <INPUT onClick="MM_popupMsg('答案：<%=rs("key")%>')" type=button value=答案 name=button<%=rs("id")%> style="font-size: 12px"></p>  
      </td>     
    </tr> 
    <%                                                                                       
    i=i+1   
    w=w+1                                                                   
    rs.movenext                                                                          
    loop                                                                                               
    end if     
    rs.close                                                
    %>  
    <tr> 
      <td width="688" height="25" bgcolor="#BBDBFF" colspan="3"> 
      <p align="center">页数：<%=currentpage%>/<% =n%>                                                                   
   	<%k=currentpage                                                                                          
   	if k<>1 then%>                                                                     
   	<a href="search.asp?pageid=1&keyword=<%=name%>">首页</a>                                                                                          
   	<a href="search.asp?pageid=<%=k-1%>&keyword=<%=name%>">上一页</a>                                                                                          
   	<%else%>                                                                      
   	首页&nbsp;上一页                                                                                          
   	<%end if%>                                                                     
   	<%if k<>n then%>                                                                                          
   	<a href="search.asp?pageid=<%=k+1%>&keyword=<%=name%>">下一页</a>                                                                                          
   	<a href="search.asp?pageid=<%=n%>&keyword=<%=name%>">尾页</a>                                                                                          
   	<%else%>                                                                      
   	下一页&nbsp;尾页                                                                                          
   	<%end if%>                                                                     
        共找到<%=totalput%>道题目</p> 
      </td> 
    </tr> 
    <tr> 
    <td colspan="3"> 
<p align="center" style="margin-top: 2; margin-bottom: 2">       
      <%        
      p=1       
      for j=1 to n step 1       
      if k=p then       
      response.write "<font color=red style=font-size:12px>"&p&"</font>&nbsp;&nbsp;"       
      else       
      response.write "<font style=font-size:12px><a href=search.asp?pageid="&p&"&keyword="&name&">"&p&"</a></font>&nbsp;&nbsp;"    
      if j mod 25=0 then   
      response.write "<p align=center style=margin-top: 2; margin-bottom: 2>"   
      end if      
      end if       
      p=p+1        
      next        
      %>
    </td>
    </tr>  
  </table> 
  </center> 
</div>
<!--#include file="end.asp"-->              
</body>                 
</html>                 