<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/function.asp"-->
<%
dim currentpage,totalpage,totalnum,recpage,urls
recpage=20
dim id,Age2,Sex,Province,City,Key,carr,ctitle,ptitle,htitle,postions
if(request.QueryString("page")<>"") then
	currentpage=Clng(request.QueryString("page"))
else
	currentpage=1
end if
if(currentpage<=0) then
	currentpage=1
end if
if(request.QueryString("levelid")<>"") then
	levelid=Clng(request.QueryString("levelid"))	
else
	levelid=0
end if
key=request.QueryString("key")
if(key<>"") then
	key=replace(key,"'","")
end if
urls="levelid="&levelid&"&key="&key

function GetLevel(id)
	dim ifselect,rs,sql,cid
	if(id<>"") then
		cid=id
	else
		cid=0
	end if
	sql="select id,title from t_flevel order by id asc"
	Set rs = conn.Execute(sql)
	if rs.eof or rs.bof then
		GetLevel="<option value=""0"">...</option>"&Chr(13)
	else	
		while not rs.eof and not rs.bof
			if(Clng(rs(0))=Clng(cid)) then
				ifselect=" selected"
			else
				ifselect=""
			end if
			GetLevel=GetLevel&"<option value="""&rs(0)&""" "&ifselect&">"&rs(1)&"</option>"&Chr(13)
			rs.movenext
		wend
	end if
	rs.close
	set rs=nothing
end function
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>店铺查询</title>
<link href="../style/global.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/common.js"></script>
<style type="text/css"> 
<!--
.tel {
	color: #128203;
}
body,td{ font-size:12px;}
.f14px{ margin:0px; padding:0px;}
.f14px a{ margin:0px 2px;}
p{margin:0px; padding:0px;}
.pages{ text-align:center; line-height:25px;}
.br{ margin:5px; clear:both;}
-->
</style>
</head>
<body>
<!--#include file="../head.asp"-->
<div class="br"></div>
<table border="0" cellspacing="0" cellpadding="0" width="960" align="center">
  <tbody>
    <tr>
      <td valign="top"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tbody>
          <tr>
            <td height="21" background="yp_files/table_bg.gif" width="2"><img name="" 
            alt="" src="" width="1" height="1" /></td>
            <td background="yp_files/table_bg.gif"><table border="0" cellspacing="0" cellpadding="0">
              <tbody>
                <tr valign="bottom" align="middle">
                  <td background="yp_files/bg_mil_0.gif" width="80"><strong><font 
                  color="#0053b7">黄页分类</font></strong></td>
                  </tr>
                </tbody>
              </table></td>
            </tr>
          <tr valign="top" align="middle">
            <td bgcolor="#eaeff4" colspan="2">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="32" align="center" bgcolor="#FFFFFF"><form id="form1" name="form1" method="get" action="?">
                    楼层：
                    <select name="levelid" id="levelid">
                    <option value="0">不限</option>
										<%=GetLevel(levelid)%>
                    </select>
                  　名称：
                  <input type="text" name="key" id="key" value="<%=key%>" />
                  <input type="submit" name="button" id="button" value="查询" />
                  </form></td>
                  </tr>
                
                
                <tr>
                  <td height="32" align="right" bgcolor="#FFFFFF">&nbsp;</td>
                  </tr>
                </table>            
              <table width="100%" border="0" cellspacing="1" cellpadding="0">
                <tr>
                  <td width="20%" align="center" bgcolor="#EBF2FC">&nbsp;</td>
                  <td width="29%" height="30" align="center" bgcolor="#EBF2FC">公司名称</td>
                  <td width="32%" align="center" bgcolor="#EBF2FC">地址</td>
                  <td width="19%" align="center" bgcolor="#EBF2FC">电话</td>
                  </tr>
                <%			
								csql="select count(*) from t_shop where 1=1"
								if(levelid>0) then
									csql=csql&" and LevelId="&levelid
								end if			
								if(key<>"") then
									csql=csql&" and Title like '%"&key&"%'"
								end if
								sql="select top "&recpage&" LevelId,Title,Address,Tel,Content,Photo from t_shop where id<=(select min(id) from (select top "&((currentpage-1)*recpage+1)&" id from t_shop where 1=1"
								if(levelid>0) then
									sql=sql&" and LevelId="&levelid
								end if			
								if(key<>"") then
									sql=sql&" and Title like '%"&key&"%'"
								end if
								sql=sql&" order by id desc) as t) and 1=1"
								if(levelid>0) then
									sql=sql&" and LevelId="&levelid
								end if			
								if(key<>"") then
									sql=sql&" and Title like '%"&key&"%'"
								end if
								sql=sql&" order by id desc"
								'response.write(sql)
								totalnum=conn.execute(csql)(0)
								totalpage=int((totalnum-1+recpage)/recpage)
								set rs=server.CreateObject("adodb.recordset")
								rs.open sql,conn,3,1
								if not rs.eof then
									carr=rs.GetRows()
								end if
								rs.close
								set rs=nothing
								if isarray(carr) then
									dim bg_color,bg_color1,bg_color2,j,catalogs
									bg_color1="#F0F7FF"
									bg_color2="#FFFFFF"
									for i=0 to ubound(carr,2)
										if(i mod 2=0) then
											bg_color=bg_color1
										else
											bg_color=bg_color2
										end if
								%>
                <tr>
                  <td align="center" bgcolor="#F5F8FA" class="padleft_10">
                  <img src="<%=carr(5,i)%>" width="158" height="135" border="0" />
                  </td>
                  <td height="30" align="left" bgcolor="#F5F8FA">&nbsp;<%=carr(1,i)%></td>
                  <td align="left" bgcolor="#F5F8FA">&nbsp;<%=carr(2,i)%></td>
                  <td align="center" bgcolor="#F5F8FA"><%=carr(3,i)%></td>
                  </tr>
                <%
										next
								else
									response.write("<tr><td colspan=""4"" height=""30"" align=""center"">暂时没有记录!</td></tr>")
								end if
							set carr=nothing
							%>
              </table></td>
            </tr>
          </tbody>
        </table>
        <div class="pages">
          <%
					dim n,p,startpage,endpage
					n=currentpage+1
					p=currentpage-1
					startpage=currentpage-5
					if(startpage<=0) then
						startpage=1
					end if
					endpage=currentpage+5
					if(currentpage<5) then
						endpage=10
					end if
					if(endpage>totalpage) then
						endpage=totalpage
					end if
					response.write("<a href=""list.asp?"&urls&"&page=1"">首</a>")
					if(currentpage>1) then
						response.write("<a href=""list.asp?"&urls&"&page="&(currentpage-1)&""">上一页</a>")
					else
						response.Write("上一页")
					end if
					'''''''''''''''''
					for j=startpage to endpage
							if(j=currentpage) then
								response.write("<a href=""#"" class=""current"">"&j&"</a>")
							else
								response.write("<a href=""list.asp?"&urls&"&page="&j&""">"&j&"</a>")
							end if
							if(j>(startPage+10)) then
								exit for
							end if
					next
					'''''''''''''''''''''''''''''''''''''
					if(currentpage<totalpage) then
						response.write("<a href=""list.asp?"&urls&"&page="&(currentpage+1)&""">下一页</a>")
					else
						response.Write("下一页")
					end if
					response.write("<a href=""list.asp?"&urls&"&page="&totalpage&""">尾</a>")
					%>
      </div></td>
    </tr>
  </tbody>
</table>
<div class="br"></div>
<!--#include file="../root.asp"-->
</body>
</html>
<%
call connclose()
%>