<!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!-- #include file="inc/wenda_reset.asp" -->
<%
dim id,currentpage,totalpage,totalnum,recpage,key,ctitle,flag
recpage=20
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("id")<>"") then
	id=Clng(request.QueryString("id"))
else
	id=0
end if
if(request.QueryString("flag")<>"") then
	flag=Clng(request.QueryString("flag"))
else
	flag=-1
end if
if(id>0) then
	set rs=conn.execute("select Title from t_wenda_catalog where id="&id)
	if not rs.eof then
		ctitle=rs(0)
	end if
	rs.close
	set rs=nothing
end if
key=request.QueryString("key")
key=replace(key,"'","")
%>
<!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><%=ctitle%>-旅游问答-<%=SiteName%></title>
<link href="../style/global.css" rel="stylesheet" type="text/css" />
<link href="style/zd.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/jquery-1.3.2.min.js"></script>
<script language="javascript">
function goto(frm)
{
	var gourl ="?id=<%=id%>&key=<%=key%>&";
	gourl += "page=" + (frm.page.value);
     var hid=parseInt(frm.hid.value);
	 if(parseInt(frm.page.value)>hid||frm.page.value<=0){
	 alert("错误！请确定你输入的数字在1-"+hid+"之间");
	 return false;
	 }
	window.location.href(gourl);
}</script>
</head>

<body>
<!--#include file="../templet/head.htm"-->
<!--#include file="nav.asp"-->
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="9"><img src="images/head_left2.gif" width="9" height="27" alt=" " /></td>
    <td background="images/head_bg2.gif"><div class="nav3"><a href="/"><%=SiteName%></a>-&gt;<a href="/wd/">旅游问答</a></div></td>
    <td width="9"><img src="images/head_right2.gif" width="9" height="27" alt=" " /></td>
  </tr>
</table>
<div class="br"></div>
<table width="960" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top">
    	<form action="/wd/search.asp" method="get">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="zd_brd">
      <tr>
        <td align="center" background="images/search_bg.gif"><img src="/wd/images/search_left.gif" width="40" height="37" alt=" " /></td>
        <td height="30" align="center" background="/wd/images/search_bg.gif">关键字：
          <input name="KeyWord" type="text" class="input_text" id="KeyWord" size="60" />
           <input name="button2" type="submit" class="input_search" id="button2" value=" " /></td>
        <td align="center" background="images/search_bg.gif"><a href="/wd/ask.asp" class="wd_btn_pub">我要提问</a></td>
      </tr>
    </table>
    </form>
      <div class="br"></div>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td class="wenda_th"><div class="txt"><img src="images/icon3.gif" width="17" height="16" alt=" " /> <%=ctitle%>-问题列表</div></td>
        </tr>
      </table>
      <div class="zd_brd_lrb">
        <table width="100%" border="0" cellpadding="0" cellspacing="1" class="wenda_list">
          <tr>
            <th width="16%">分类</th>
            <th width="34%">标题</th>
            <th width="12%">状态</th>
            <th width="19%">用户</th>
            <th width="19%">日期</th>
          </tr>
          <%
						csql="select count(*) from t_wenda where IsCheck=1"
						if(id>0) then
							csql=csql&" and CatalogId="&id
						end if
						if(flag>=0) then
							csql=csql&" and [Status]="&flag
						end if
						if(key<>"") then
							csql=csql&" and Title like '%"&key&"%'"
						end if
						sql="select top "&recpage&" id,UserId,Title,[Status],PubDate,Hits,CatalogTitle,CatalogId from t_wenda where id<=(select min(id) from (select top "&((currentpage-1)*recpage+1)&" id from t_wenda where IsCheck=1"
						if(id>0) then
							sql=sql&" and CatalogId="&id
						end if
						if(flag>=0) then
							sql=sql&" and [Status]="&flag
						end if
						if(key<>"") then
							sql=sql&" and Title like '%"&key&"%'"
						end if
						sql=sql&" order by id desc) as t) and IsCheck=1"
						if(id>0) then
							sql=sql&" and CatalogId="&id
						end if
						if(flag>=0) then
							sql=sql&" and [Status]="&flag
						end if
						if(key<>"") then
							sql=sql&" and Title like '%"&key&"%'"
						end if
						sql=sql&" order by id desc"
						allrec=conn.execute(csql)(0)
						totalpage=int((allrec-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
							for i=0 to ubound(carr,2)
						%>
          <tr>
            <td align="center" bgcolor="#FFFAEF">[<a href="list.asp?id=<%=carr(7,i)%>"><%=carr(6,i)%>]</a></td>
            <td bgcolor="#FFFAEF" class="padl10"><a href="show.asp?id=<%=carr(0,i)%>"><%=carr(2,i)%></a></td>
            <td align="center" bgcolor="#FFFAEF"><%if(carr(3,i)=0) then response.Write("未解决") else response.Write("已解决") end if%></td>
            <td align="center" bgcolor="#FFFAEF"><%=carr(1,i)%></td>
            <td align="center" bgcolor="#FFFAEF"><%=carr(4,i)%></td>
          </tr>
          <%
						next
					else
						response.write("<p align=""center"">暂时没有记录!</p>")
					end if
					set carr=nothing
					%>
        </table>
      </div>
      <div class="br"></div>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="32"><div align="center">
              <div class="page">
              <%
              dim n,p,startpage,endpage,j
              n=currentpage+1
              p=currentpage-1
              startpage=currentpage-5
              if(startpage<=0) then
                startpage=1
              end if
              endpage=currentpage+5
              if(endpage>totalpage) then
                endpage=totalpage
              end if
							response.write("<a href=""?"&urls&"&page=1"">首页</a> ")
              if p>0then
                response.write("<a class=""number"" href=""?"&urls&"&page="&cstr(p)&""">&lt;&lt;</a> ")
              else 
                response.write("<a class=""number"" href=""#"">&lt;&lt;</a> ")
              end if 
              '''''''''''''''''
              for j=startpage to endpage
                  if(j=currentpage) then
                    response.write("<a class=""number hover"">"&j&"</a>")
                  else
                    response.write("<a class=""number"" href=""?"&urls&"&page="&j&""">"&j&"</a> ")
                  end if
                  if(j>(startPage+10)) then
                    exit for
                  end if
              next
              '''''''''''''''''''''''''''''''''''''
              if (n-1)*recpage>=Clng(totalnum) then 
                response.Write("<a class=""number"" href=""#"">&gt;&gt;</a> ")
              else
                response.Write("<a class=""number"" href=""?"&urls&"&page="&cstr(n)&""">&gt;&gt;</a> ")
              end if
              response.write(" <a href=""?"&urls&"&page="&totalpage&""">末页</a> ")
              response.Write(""&currentpage&"/"&totalpage&"页")
              %>
						</div>
          </div></td>
        </tr>
    </table>
      <div class="br"></div>
      <div class="br"></div></td>
    <td width="5">&nbsp;</td>
    <td width="220" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="zd_brd">
      <tr>
        <td height="29" class="zd_topic"><img src="images/icon1.gif" alt=" " width="25" height="21" align="absmiddle" /> <span class="zd_topic_txt">知道分类</span></td>
      </tr>
      <tr>
        <td>
        <div class="zd_catalogs">
        	<ul>
          	<%
						set rs=conn.execute("select id,title from t_wenda_catalog order by id asc")
						while not rs.eof
						%>
            <li><a href="/wd/list.asp?id=<%=rs(0)%>"><%=rs(1)%></a></li>
            <%
							rs.movenext
						wend
						rs.close
						set rs=nothing
						%>           
          </ul>
        </div>
        </td>
      </tr>
    </table>
      <div class="br"></div>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="zd_brd">
        <tr>
          <td height="29" class="zd_topic"><img src="images/icon2.gif" alt=" " width="18" height="13" /> <span class="zd_topic_txt">关注排行</span></td>
        </tr>
        <tr>
          <td><div class="rank2">
            <ul>
              <%
						set rs=conn.execute("select top 10 id,UserId,Title,[Status],PubDate,Hits from t_wenda where IsCheck=1 order by Hits desc,id desc")
						while not rs.eof
						%>
            <li><a href="show.asp?id=<%=rs(0)%>"><%=rs(2)%></a></li>          
						<%
              rs.movenext
            wend
            rs.close
            set rs=nothing
            %>            
            </ul>
          </div></td>
        </tr>
    </table></td>
  </tr>
</table>
<!--#include file="../templet/root.htm"-->
</body>
</html>
<%
call connclose()
%>