<!--#include file="conn.asp" -->
<!--#include file="Include/Common.Inc.Asp" -->
<% 
Dim action
action=ReqString("action")

Select Case action
	Case "read"
		Call read()
	Case Else
		Call main()
End Select

Sub main() 

Dim CatId,objRs,Cat_Name,title
CatId=ChkNumeric(ReqString("Id"))

Set objRs=Execute("SELECT * FROM Category WHERE Id="&CatId)
If Not objRs.Eof Then
	Cat_Name=objRs("CategoryName")
End If
objRs.Close
title=Cat_Name&" - 名人俱乐部"
 %>
<!--#include file="Top.asp" -->
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3" bgcolor="#f9bbbc" height="1"></td>
  </tr>
  <tr> 
    <td width="3" bgcolor="#f9bbbc"></td>
   <td width="210" align="right" valign="top"><!-- #include file="left.asp" --></td>
   <td width="1" bgcolor="#f9bbbc"></td>
    <td  align="left" width="686" valign="top" bgcolor="#f9bbbc">
    <table border="0" width="684"align="center" cellpadding="0" cellspacing="0" height="400">
  <tr>
    <td width="10" height="12" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
    <td width="508" valign="top" bgcolor="#FFFFFF"><span>您所在的位置：<a href="Index.Asp">首页</a> &gt; <%= Cat_Name %></span></td>
  </tr>
  <tr>
    <td height="350" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
    <td valign="top" bgcolor="#FFFFFF"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="12" colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td height="30" colspan="2" valign="top" background="images/index_r4_c111.jpg"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="26" align="left" background="images/index_r2_c21.jpg" class="zuzhi"><%= Cat_Name %></td>
            <td width="7%" background="images/index_r2_c21.jpg"></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td width="6%" height="56" align="center" valign="middle" background="images/index_r6_c2.jpg">&nbsp;</td>
        <td width="94%" valign="top" background="images/index_r6_c2.jpg"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top" background="images/index_r9_c71.jpg"><table width="100%" border="0" cellpadding="0" cellspacing="0">
<% 
Dim CountPage,CountNum,i,CurrentPage,intYear, intMonth ,intDay
Dim Art_Title

CurrentPage=ChkNumeric(ReqString("page"))
If  CurrentPage=0 Then CurrentPage=1
If CatId=5 Then
	Set objRs  = pageRecordSet("SELECT title,id,ptime FROM Article WHERE CategoryId="&CatId&" Order by OrderId",1,1,30,CurrentPage)
Else
	Set objRs  = pageRecordSet("SELECT title,id,ptime FROM Article WHERE CategoryId="&CatId&" Order by OrderId",1,1,15,CurrentPage)
End If
	CountPage = objRs.PageCount
	Countnum = objRs.RecordCount
	If  Countpage=0 Then Countpage=1
i=1
If  objRs.Eof Then
 %>
              <tr>
                <td>&nbsp;</td>
                <td height="28" colspan="2" valign="bottom">暂无记录!</td>
                </tr>
<% 
End If

Do While Not objRs.Eof And i<=objRs.PageSize

Art_Title=objRs("title")
If Len(Art_Title)>40 Then
	Art_Title=Left(Art_Title,40)&"..."
End If

intYear = Year(objRs("Ptime"))
intMonth = Month(objRs("Ptime")):If intMonth<10 Then intMonth="0"&intMonth
intDay = Day(objRs("Ptime")):If intDay<10 Then intDay="0"&intDay
 %>
              <tr>
                <td width="6%">&nbsp;</td>
                <td width="76%" valign="bottom"><a href="?action=read&id=<%= objRs("id") %>" title="<%= objRs("title") %>"><%= Art_Title %></a></td>
                <td width="18%" height="26" valign="bottom">&nbsp;</td>
              </tr>
<% 
objRs.MoveNext
i=i+1
Loop
objRs.Close
%>           
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td align="right">共 <span class="lk4"><%= countnum %></span> 条纪录 当前第<span class="lk4"><%= CurrentPage %>/<%= CountPage %></span>页
            <% If CurrentPage<>1 Then %>
              <a href="?id=<%= CatId %>&amp;page=1">首页</a>
              <% Else %>
              <font color="Gray">首页</font>
              <% End If %>
            |
            <% If CurrentPage>1 Then %>
            <a href="?id=<%= CatId %>&amp;page=<%= CurrentPage-1 %>">上一页</a>
            <% Else %>
            <font color="Gray">上一页</font>
            <% End If %>
            |
            <% If CurrentPage<CountPage Then %>
            <a href="?id=<%= CatId %>&amp;page=<%= CurrentPage+1 %>">下一页</a>
            <% Else %>
            <font color="Gray">下一页</font>
            <% End If %>
            |
            <% If CurrentPage<CountPage Then %>
            <a href="?id=<%= CatId %>&amp;page=<%= CountPage %>">末页</a>
            <% Else %>
            <font color="Gray">末页</font>
            <% End If %>
            转到第
            <select name="page" onChange="window.open(this.options[this.selectedIndex].value,'_self')">
              <% 
For i=1 to CountPage
 %>
              <option value="?id=<%= CatId %>&amp;page=<%= i %>"<% If CurrentPage=i Then %>  Selected<% End If %>><%= i %></option>
 <% Next %>
            </select>
            页 </td>
        </tr>
      </table></td>
  </tr>
    </table></td>
  </tr>
</table>
<% 
End Sub

Sub read()

Dim art_id,art_title,art_content,art_ptime,cat_id,cat_name,title
Dim objRs,catRs
art_id=ChkNumeric(ReqString("id"))

Set objRs=Execute("SELECT * FROM Article WHERE id="&art_id)
If Not objRs.Eof Then
	art_title=objRs("title")
	art_content=objRs("content")
	art_ptime=objRs("ptime")
	cat_id=objRs("categoryid")
	Set catRs=Execute("SELECT * FROM Category WHERE id="&cat_id)
	If Not catRs.Eof Then
		cat_name=catRs("categoryname")
	End If
	catRs.Close
Else
	ErrMsg("不存在的记录!")
End If
objRs.Close

Dim disp_content,page,countpage,pagestr,i
page=ChkNumeric(ReqString("page"))
If page=0 Then page=1
If  Not isNull(art_content) Then 
    art_content=Split(art_content,"{$pagebreak}")
	countpage=Ubound(art_content)
	If page>countpage+1 Then page=countpage+1
	If countpage>=0 Then disp_Content=art_content(page-1)
End If

If  countpage>0 Then
	pagestr="共"&(countpage+1)&"页&nbsp;&nbsp;"
	
	For i=1 to (countpage+1)
		If page=i Then
			pagestr=pagestr&"<a href=""?id="&art_id&"&action=read&page="&i&""" style=""text-decoration:underline; font-weight:bold;"">第"&i&"页</a>&nbsp;"
		Else
			pagestr=pagestr&"<a href=""?id="&art_id&"&action=read&page="&i&""" style=""text-decoration:underline;"">第"&i&"页</a>&nbsp;"
		End If
	Next
End If

title=cat_name&" - 名人俱乐部"
 %>
<!--#include file="Top.asp" -->
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="3" bgcolor="#f9bbbc" height="1"></td>
  </tr>
  <tr> 
    <td width="3" bgcolor="#f9bbbc"></td>
   <td width="210" align="right" valign="top"><!-- #include file="left.asp" --></td>
   <td width="1" bgcolor="#f9bbbc"></td>
    <td  align="left" valign="top" width="686" bgcolor="#f9bbbc"><table width="684" border="0" align="center" cellpadding="0" cellspacing="0" height="400">
  <tr>
    <td align="center" height="1" background="images/footer.jpg" colspan="2"></td>
  </tr>
  <tr>
    <td width="10" height="12" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
    <td width="508" valign="top" bgcolor="#FFFFFF"><span>您所在的位置：<a href="Index.Asp">首页</a> &gt; <a href="Article.asp?id=<%= cat_id %>"><%= Cat_Name %></a></span></td>
  </tr>
  <tr>
    <td height="440" valign="top" bgcolor="#FFFFFF">&nbsp;</td>
    <td valign="top" bgcolor="#FFFFFF"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="26">&nbsp;</td>
      </tr>
      <tr>
        <td height="26" class="zuzhi">所在类别：<a href="Article.asp?id=<%= cat_id %>"><%= Cat_Name %></a></td>
        </tr>
    </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="28" colspan="3" align="center" class="jiachu" style="font-size:16px;" width="640"><%= art_title %></td>
        </tr>
        <tr>
          <td height="26" colspan="2" align="right" valign="bottom">&nbsp;</td>
          <td width="43%">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="3" valign="top" width="640" style="font-size:14px;line-height:20px;"><%= disp_Content %></td>
        </tr>
      </table>
      <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td height="30" align="right"><%= pagestr %></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table></td>
  </tr>
    </table></td>
  </tr>
</table>
<% 
End Sub
 %>
<!--#include file="Bottom.asp" -->