<!--#include file="conn.asp"-->
<!--#include file="config.asp"--> 


<%
Dim Intcatid,strOrder,strcat,strcategory
id = 0
id=SafeRequest("id",1)
strcat = "<a href=newslist.asp><FONT COLOR=#333333>所有资讯</font></a>"
strtitle="所有资讯"

If id = 0 Then
strcat = strcat &"－><a href=newslist.asp?id=0 >网店动态</a> "
strtitle="网店动态"
elseif id=1001 then
strcat = strcat &"－><a href=newslist.asp?id=1001 >商品资讯</a>"
strtitle="商品资讯"
elseif  id="" then
 strcat = strcat &"－><a href=newslist.asp >所有资讯</a> "
strtitle="所有资讯"
else
 set rs=server.CreateObject("adodb.recordset")
rs.open "select category from category where categoryid="&Intcatid&" ",conn,1,1 
strcategory = trim(rs("category"))
strtitle=trim(rs("category"))
strcat = strcat &"－><a href=newslist.asp?id="&rs("categoryid")&" >"& strcategory &"</a> "
rs.close 
set rs=nothing
End If
webtitle=strtitle
webkeywords=strtitle
webdescription=strtitle&"|"&webname
%>
<!--#include file="include/header.asp"--> 
<TABLE width="980" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" class=table-zuoyou bgcolor="#FFFFFF" >
<TR><TD HEIGHT="30" bgcolor="#f1f1f1" width="75" class=table-xia><FONT color="#ffffff">&nbsp;<b><FONT COLOR=#999999>您的位置：</b></FONT></TD>
<td class=table-xia>&nbsp;<a href="index.asp"><FONT COLOR=#333333><%=webname%></font></a><font color="#ffffff">－&gt;</font><a href="newslist.asp"><FONT COLOR=#333333><% = strcat %></font></a></td></TR></table>

<%
				Const MaxPerPage=20
   				dim totalPut   
   				dim CurrentPage
   				dim TotalPages
   				dim j
   				dim sql
    			if Not isempty(SafeRequest("page",1)) then
      				currentPage=Cint(SafeRequest("page",1))
   				else
      				currentPage=1
   				end if 
        set rs=server.CreateObject("adodb.recordset")
        if id<>"" then
	rs.open "select categoryid ,newsid,newsname,newscontent,addname,adddate from news where  categoryid="&id&"    Order By adddate desc ",conn,1,1
          else
       rs.open "select categoryid ,newsid,newsname,newscontent,addname,adddate from news   Order By adddate desc ",conn,1,1
        end if
				
  				if rs.eof And rs.bof then
       				Response.Write "<p align='center' class='contents'> 您还没有添加新闻！</p>"
   				else
	  				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
            			showContent
            			showpage totalput,MaxPerPage,"newslist.asp"
       				else
          				if (currentPage-1)*MaxPerPage<totalPut then
            				rs.move  (currentPage-1)*MaxPerPage
            				dim bookbrand
            				bookbrand=rs.bookbrand
            				showContent
             				showpage totalput,MaxPerPage,"newslist.asp"
        				else
	        				currentPage=1
           					showContent
           					showpage totalput,MaxPerPage,"newslist.asp"
	      				end if
	   				end if
   				   				end if

   				sub showContent
       			dim i
	   			i=0

			%> 
<TABLE width="980" BORDER="0" CELLSPACING="0" CELLPADDING="0" align="center" class=table-zuoyou bgcolor="#FFFFFF" >
<TR ALIGN="center" height=30> 
<TD width="50%" class=table-youxia><FONT COLOR=#333333>新闻主题</font></TD>
<TD width="25%" class=table-youxia><FONT COLOR=#333333>发布人</font></TD>
<TD width="25%" class=table-xia><FONT COLOR=#333333>发布时间</font></TD></TR> 
<%do while not rs.eof%>
 <TR ALIGN="center" height=25>
 <TD class=table-youxia STYLE="PADDING-LEFT: 6px" align="left">
<% if rs("categoryid")=0 then %>
  [<a href=newslist.asp?id=0 >商城动态</a>]
<% elseif rs("categoryid")=1001 then %>
 [<a href=newslist.asp?id=1001 >商品知识</a>]
<% else %>
<% set rsnews=server.CreateObject("adodb.recordset")
If rs("categoryid") <> 0 or  rs("categoryid")<>1001 Then
rsnews.open "select category, categoryid from category where categoryid="&rs("categoryid")&" ",conn,1,1 

 %>
[<a href=newslist.asp?id=<%=rs("categoryid")%> ><%=  trim(rsnews("category")) %></a>]
<% Else %>
 <a href=newslist.asp >[其他]</a>]
<%End If%>
<%rsnews.close

set rsnews=nothing
%>
<% end if %>
  <a href=news.asp?id=<%=rs("newsid")%>><%=trim(rs("newsname"))%></a></TD>
 <TD class=table-youxia> <FONT COLOR=#333333><%=trim(rs("addname"))%></font></TD>
 <TD class=table-xia><FONT COLOR=#333333><%=rs("adddate")%></font></TD></TR> 
<%i=i+1
			if i>=MaxPerPage then Exit Do
			rs.movenext
		  loop
		  rs.close
		  set rs=nothing%><tr><td colspan="3"><%  
				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 %>
				
				<form method=Post action= <% = filename %>>
				<p align='center'> 
				<%
				If CurrentPage<2 Then  %>
				<FONT COLOR=#333333>首 页 上一页
				<%
				Else   %>
				<a href=<% = filename %>?page=1><FONT COLOR=#333333>首 页</a>
				<a href=<% = filename %>?page=<% = CurrentPage-1 %>><FONT COLOR=#333333>上一页</a>
				<%
				End If	
				If n-currentpage<1 Then  %>
				<FONT COLOR=#333333>下一页 末 页
				<%
				Else   %>
				<a href=<% = filename %>?page=<% = (CurrentPage+1) %>><FONT COLOR=#333333>下一页</a>
				<a href=<% = filename %>?page=<% = n %>><FONT COLOR=#333333>末 页</a>
				<%
				End If  %>
					<FONT COLOR=#333333>第 <b><% = CurrentPage %></b> <FONT COLOR=#333333>页 共 <b><% = n %></b> 页
				共&nbsp;<b><% = totalnumber %></b>&nbsp;条新闻　每页 <b><% = maxperpage %></b> 条新闻
				转到第：<input type='text' name='page' size=2 maxlength=10 class=smallInput value=<% = currentpage %>>
				页</font><input type='submit'  class='contents' value='跳转' name='cndok'></form>
				<%
				End Function  
			%> </td></tr></TABLE>
			<!--#include file="include/footer.asp"--> 
<script language=javascript>
function mm()
{
   var a = document.getElementsByTagName("input");
   if(a[0].checked==true){
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = false;
   }
   else
   {
   for (var i=0; i<a.length; i++)
      if (a[i].type == "checkbox") a[i].checked = true;
   }
}
</script>
