<!--#include file="articleconn.asp"--> 
<!--#include file="INC/fun.inc"-->
<!--#include file="top.asp" -->
<link rel="stylesheet" href="../../images/css.css" type="text/css">
<script language="javascript">
function popwin2(id,path)
{		window.open("openarticle.asp?id="+id,"","");
}
</script>
<%
   dim rs
   MaxPerPage=20
   dim totalPut   
   dim CurrentPage
   dim TotalPages
   dim i,j

   dim typename
   dim ty
   typeid=request("typeid")
   if not isempty(request("page")) then
      currentPage=cint(request("page"))
   else
      currentPage=1
   end if
      dim rstype
   dim typesql
   dim typeid,typename1
   if not isEmpty(request("typeid")) then
	typeid=request("typeid")
   else
	typeid=0
   end if
 set rstype=server.createobject("adodb.recordset")
  typesql="select * from type where typeid="&typeid&""
 rstype.open typesql,conn,1,1
 if not rstype.eof then
	typename1=rstype("type")
 else typename1="全部文章"	
 end if
rstype.close
set rst=server.CreateObject("ADODB.RecordSet") 
%>
<div align="center">
  <center>
<table border="0" cellpadding="0" cellspacing="0" width="770" style="border-collapse: collapse" bordercolor="#111111">
  <tbody>
  <tr><td width="685">
<%
dim sql
if typeid=0 then
    sql="select * from learning order by articleid desc"
else
    sql="select * from learning where typeid="+cstr(typeid)+" order by articleid desc"
end if   
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
 if rs.eof and rs.bof then
       response.write "<p align='center'> 还 没 有 任 何 文 章</p>"
   else
      totalPut=rs.recordcount
      totalPut=rs.recordcount
      if currentpage<1 then
          currentpage=1
      end if
      if (currentpage-1)*MaxPerPage>totalput then
	   if (totalPut mod MaxPerPage)=0 then
	     currentpage= totalPut \ MaxPerPage
	   else
	      currentpage= totalPut \ MaxPerPage + 1
	   end if


      end if
       if currentPage=1 then
           showpage totalput,MaxPerPage,"index.asp"
           showContent
           showpage1 totalput,MaxPerPage,"index.asp"
       else
          if (currentPage-1)*MaxPerPage<totalPut then
            rs.move  (currentPage-1)*MaxPerPage
            dim bookmark
            bookmark=rs.bookmark
           showpage totalput,MaxPerPage,"index.asp"
           showContent
           showpage1 totalput,MaxPerPage,"index.asp"
        else
	        currentPage=1
           showpage totalput,MaxPerPage,"index.asp"
           showContent
           showpage1 totalput,MaxPerPage,"index.asp"
	      end if
	   end if
   rs.close
   end if
	        
   set rs=nothing  
   conn.close
   set conn=nothing
  

sub showContent
       dim i
	   i=0
%><span style="font-size: 9pt"> </span>
<div align="center">
  <center>
<table cellspacing="0" cellpadding="0" border="0" width="617" style="border-collapse: collapse" bordercolor="#111111">
<tbody>
<tr bgcolor="#FF99CC">
<td width="514"><span style="font-size: 9pt">&nbsp;</span><font color="#FFFFFF"><span style="font-size: 9pt">标　题</span></font></td>
<td width="77" align="center">
<font color="#FFFFFF" style="font-size: 9pt">时　间</font></td>
<td width="26" align="center">
<font color="#FFFFFF" style="font-size: 9pt">人气</font></td>
</tr>
<tr>
 <td height="4" colspan="3" bgcolor="#ffe8f0" width="617"></td>
<tr>
           <%do while not rs.eof%><span style="font-size: 9pt">
           <tr height="24">
           <td width="514"><li><a href="javascript:popwin2(<%=rs("articleid")%>)" class="a06"><%=rs("title")%></a></td>
           <td align="center" width="77"><%=GetDate(rs("dateandtime"))%></td>
           <td align="center" width="26"><%=rs("hits")%></td>
           </tr>
            <% i=i+1
	      if i>=MaxPerPage then exit do
	      rs.movenext
	   loop
		%> </span>
<tr>
 <td height="10" colspan="3" width="617"></td>
<tr>
 <td height="1" colspan="3" background="../images/hline.gif" width="617"></td>
</tbody>
</table>          
      </center>
</div>
      <%
   end sub 
   
   
   
function showpage(totalnumber,maxperpage,filename)
  dim n
  if totalnumber mod maxperpage=0 then
     n= totalnumber \ maxperpage
  else
     n= totalnumber \ maxperpage+1
  end if
  Response.Write  "<table border=""0"" cellspacing=""0"" cellpadding=""0"" width=""100%"" height=30>"
  response.write  "<tr><td>"
  Response.Write  "共有文章: <b><font color=""red"">"&totalnumber&"</font></b> 篇　页次: <font color=""red""><b>"&CurrentPage&"</b> / <b>"&n&"</b></font> 页</td>"
  response.write "<td align=right>"
  if CurrentPage<2 then
    response.write "上一页&nbsp;"
  else
    response.write "<a href="&filename&"?typeid="&typeid&"&page="&CurrentPage-1&">上一页</a>&nbsp;"
  end if
  if n-currentpage<1 then
    response.write "下一页"
  else
    response.write "<a href="&filename&"?typeid="&typeid&"&page="&(CurrentPage+1)
    response.write ">下一页</a>"
  end if
  Response.Write "</td></tr></table>"
end function



function showpage1(totalnumber,maxperpage,filename)
  dim n
  if totalnumber mod maxperpage=0 then
     n= totalnumber \ maxperpage
  else
     n= totalnumber \ maxperpage+1
  end if
  Response.Write  "<table border=""0"" cellspacing=""0"" cellpadding=""0"" width=""100%"" height=30><tbody>"
%><span style="font-size: 9pt"> </span>
<form action=<%response.write ""&filename&"?typeid="&typeid&""%> method="POST">
<%
  response.write "<tr><td>"
  if CurrentPage<2 then
    response.write "首页 上一页&nbsp;"
  else
    response.write "<a href="&filename&"?typeid="&typeid&"&page=1&>首页</a>&nbsp;"
    response.write "<a href="&filename&"?typeid="&typeid&"&page="&CurrentPage-1&">上一页</a>&nbsp;"
  end if
  if n-currentpage<1 then
    response.write "下一页 末页"
  else
    response.write "<a href="&filename&"?typeid="&typeid&"&page="&(CurrentPage+1)
    response.write ">下一页</a> <a href="&filename&"?typeid="&typeid&"&page="&n&">末页</a></td>"
  end if
%><span style="font-size: 9pt"> </span>
<td align=right width="201">
<span style="font-size: 9pt">转到 <input type="Text" name="page" value="<%=CurrentPage%>" size="3" maxlength="3" class="put"> 页 
</span>
</td></tr></form></tbody></table>
  </center>
</div>

<%  
end function
%>
</td></tr>
</tbody>
</table>
<!--#include file="../../copyright.asp" -->

<%
Function RmHtml(fString)
	fString = Replace(fString, CHR(13), " ")
	fString = Replace(fString, CHR(10) & CHR(10), " ")
	fString = Replace(fString, CHR(10), " ")
	fString = Replace(fString, "<br>", " ")
	fString = Replace(fString, "<BR>", " ")
	fString = Replace(fString, "<Br>", " ")
	fString = Replace(fString, "<bR>", " ")
	fString = Replace(fString, "<p>", " ")
	fString = Replace(fString, "<P>", " ")
	fString = replace(fString, ">", "&gt;")
	fString = replace(fString, "<", "&lt;")
        RmHtml=fString
End Function
%>