<!--
whilvydy 新闻发布系统
-->

<%@ page contentType="text/html; charset=GB2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="java.io.*" %> 
<%@ page import="java.util.*" %>

<%@ include file="function/parameter.jsp" %>

<jsp:useBean id="NewsBean" scope="page" class="net.jspcn.db.DbConnect" />
<jsp:useBean id='StrTool' scope='page' class='net.jspcn.tool.StringProcess' />

<%
int intPageCount,intPageSize,intCurrentPage,intRowCount,i;
intPageSize = param[2];

int type_id,board_id;
if(request.getParameter("type_id")==null||"".equals(request.getParameter("type_id")))
type_id = 1;
else
type_id = Integer.parseInt(request.getParameter("type_id"));

if(request.getParameter("board_id")==null||"".equals(request.getParameter("board_id")))
board_id = 1;
else
board_id = Integer.parseInt(request.getParameter("board_id"));

ResultSet rs;
String sql,board_name;

if("".equals(request.getParameter("board_name"))||request.getParameter("board_name")==null)
board_name = "更多新闻...";
else
board_name = request.getParameter("board_name");

NewsBean.openConnection();
%>

<%@ include file = "function/header1.jsp" %>
<%=board_name%>
<%@ include file = "function/header3.jsp" %>
<br><span class=typename><%=board_name%></span><br><br>
<table width="600"  border="1" cellspacing="0" cellpadding="0"  bordercolor="#00CC66"  borderColorDark="#FFFFFF" borderColorLight="#00CC66">
      <tr> 
    <td width="7%"> 
      <div align="center">编号</div>
    </td>
    <td width="35%"> 
      <div align="center">新闻标题</div>
    </td>
    <td width="15%"> 
      <div align="center">新闻作者</div>
    </td>
    <td width="15%"> 
      <div align="center">新闻来源</div>
    </td>
    <td width="10%"> 
      <div align="center">访问次数</div>
    </td>
    <td width="18%"> 
      <div align="center">新闻时间</div>
    </td>
   </tr>
<%
	if(request.getParameter("page")==""||request.getParameter("page")==null)
		intCurrentPage = 1;
	else
	{
		intCurrentPage = Integer.parseInt(request.getParameter("page"));
		if(intCurrentPage<1) intCurrentPage = 1;
	}									//得到当前页数
	
	sql = "select * from "+news_table+" where type_id="+type_id+" and board_id="+board_id+" order by news_id desc";
	rs = NewsBean.executeQuery(sql);
	rs.last();
	intRowCount = rs.getRow();
	intPageCount = (intRowCount+intPageSize-1)/intPageSize;
	if(intCurrentPage>intPageCount) intCurrentPage=intPageCount;		//对当前页数的控制
		
	if(intPageCount>0)
	{	
	rs.absolute((intCurrentPage-1)*intPageSize+1);	
	//for(color=0,i=0;i<intPageSize&&!rs.isAfterLast();color++,i++)		
	i=0;
	
	do {
%>
  <tr> 
    <td width="7%"> 
      <div align="center"><%=rs.getString("news_id")%></div>
    </td>
    <td width="35%"> 
      <div align="center"><a href="newsdetail.jsp?news_id=<%=rs.getString("news_id")%>" target=_blank><%=rs.getString("news_title")%></a></div>
    </td>
    <td width="15%"> 
      <div align="center"><%=rs.getString("news_author")%></div>
    </td>
    <td width="15%"> 
      <div align="center"><%=rs.getString("news_source")%>&nbsp;</div>
    </td>
    <td width="10%"> 
      <div align="center"><%=rs.getString("news_hits")%></div>
    </td>
    <td width="18%"> 
      <div align="center"><%=rs.getString("news_time").substring(0,10)%></div>
    </td>
   </tr>
<%	
	i++;
	}
	while(rs.next()&&i<intPageSize);
	}
%>
</table>
<br>
<%
	if(intCurrentPage == 1) { 
		%> 首页 前页 <% }
	else
		out.println("<a href='more_news.jsp?page=1&type_id="+type_id+"&board_id="+board_id+"&board_name="+board_name+"'>首页</a> <a href='more_news.jsp?page="+(intCurrentPage-1)+"&type_id="+type_id+"&board_id="+board_id+"&board_name="+board_name+"'>前页</a> ");
	
	if(intCurrentPage==intPageCount) {
		%>后页 末页<% }
	else
		out.println("<a href='more_news.jsp?page="+(intCurrentPage+1)+"&type_id="+type_id+"&board_id="+board_id+"&board_name="+board_name+"'>后页</a> <a href='more_news.jsp?page="+intPageCount+"&type_id="+type_id+"&board_id="+board_id+"&board_name="+board_name+"'>末页</a> ");

%>

  <%
  NewsBean.close();
  %>
  <%@ include file = "function/feeder.jsp" %>
