<!-- #include file="Inc.asp" -->
<!--#include file="ydzq.asp"-->
<%call head()
dim TP,Action,bbsid
Action=Request("Action")
bbsid=Request("bbsid")
IF  Action="ok" Then
	call search
else

	call main
end if
sub main
 if saytk<>1 then
	Response.write "<form name=""form"" method=""post"" action=""searchuser.asp?saytk="&saytk&"&amp;sid="&sid&""">"
end if
response.write "<card title='搜索会员'><p>"
response.write "请输入关键词:<br/>"
response.write "<input name=""keyword"" value="""" title=""输入关键词""/><br/>"
response.write "<select name=""sear"" value=""1"">"
response.write "<option value=""1"">按昵称搜索</option>"
response.write "<option value=""2"">按ID搜索</option>"
response.write "<option value=""3"">按城市搜索</option>"
response.write "</select><br/>"
if saytk<>1 then
response.write "<input type=""hidden"" name=""action"" value=""ok""/>"
response.write "<input type=""hidden"" name=""bbsid"" value="""&bbsid&"""/>"
%>
<input type="submit" name="Submit" value="确认搜索"></form><br/><%
else
response.write "<anchor>搜会员<go href=""searchuser.asp?saytk="&saytk&"&amp;sid="&sid&""" method=""post"">"
response.write "<postfield name=""keyword"" value=""$(keyword)""/>"
response.write "<postfield name=""sear"" value=""$(sear)""/>"
response.write "<postfield name=""bbsid"" value="""&bbsid&"""/>"
response.write "<postfield name=""Action"" value=""ok""/>"
response.write "</go></anchor><br/>"
end if
end sub

sub search

Call saycarda("搜索结果")
dim keyword,sear,sear2,times
keyword=request("keyword")
if keyword="" then keyword="保密"

sear=request("sear")
if sear="" or IsNumeric(sear)=False then
  Call Error("搜索类型无效！")
  end if
sear = abs(sear)
dim gettxt
if sear=1 then
gettxt="select ID,name from users where name like '%" & keyword & "%'"
elseif sear=2 then
if keyword="" or IsNumeric(keyword)=False then
  Call Error("以ID搜索时请输入数字！")
  end if
gettxt="select ID,name from users where ID =" & keyword & ""
elseif sear=3 then
gettxt="select ID,name from users where city like '%" & keyword & "%'"
else
gettxt="select ID,name from users where name like '%" & keyword & "%'"
end if
  gettxt = gettxt & " ORDER BY ID DESC"

set rs=Server.CreateObject("ADODB.Recordset")
rs.open gettxt, conn,1,1
If Not rs.eof	Then
Dim PageSize,i
	PageSize=10							
	Dim Count,page,pagecount,gopage	
	gopage="searchuser.asp?Action=ok&amp;bbsid="&bbsid&"&amp;keyword="&keyword&"&amp;sear="&sear&"&amp;saytk="&saytk&"&amp;sid="&sid&"&amp;"
	Count=rs.recordcount
	page=int(request.QueryString ("page"))
	if page<=0 or page="" then page=1    
	pagecount=(count+pagesize-1)\pagesize
        if page>pagecount then page=pagecount	
	rs.move(pagesize*(page-1))
        response.write ("共:"&count&"位会员<br/>")				
	For i=1 To PageSize       						
	If rs.eof Then Exit For	
response.write ""&i+(page-1)*PageSize&"."
Response.write "<a href=""uinfo.asp?id="&rs("id")&"&amp;saytk="&saytk&"&amp;sid="&sid&""">"&ubb(rs("name"))&"(ID:"&usb(rs("id"))&")</a><br/>"
rs.moveNext
 	Next
	'response.write "<br/>"&chr(13)
	if page-pagecount<0 then response.write "<a href="""&gopage&"page="&page+1&""">下一页</a>"&chr(13)
	if page>1 then response.write "<a href="""&gopage&"page="&page-1&""">上一页</a>"&chr(13)

response.write "<br/>("&page&"/"&pagecount&")共"&count&"人"
	if pagecount>1 then response.write "<input name=""page"" format=""*N"" value="""&page&""" type=""text"" maxlength=""5"" emptyok=""true"" size=""2""/><a href="""&gopage&"page=$(page)"">页</a>"

response.write "<br/>"
Else

Response.write "没有符合条件的会员<br/>"
end if
rs.close
set rs=nothing
response.write "<br/><a href=""searchuser.asp?bbsid="&bbsid&"&amp;saytk="&saytk&"&amp;sid="&sid&""">重新搜索</a><br/>"
end sub
conn.close
set conn=Nothing
If saytk=1 then
Response.write "<anchor>返回上级<prev/></anchor>"
End if
if bbsid<>"" then
response.write "<br/><a href=""board.asp?bbsid="&bbsid&"&amp;saytk="&saytk&"&amp;sid="&sid&""">返回论坛</a>"
end if
%>
<!--#include file="fanhui.asp"-->
</p></card>
</wml>