?? mnews.jsp
字號:
<%@ include file="../conn.jsp"%>
<% String flag = (String) session.getValue("flag");
if((flag==null)|(flag=="")){
response.sendRedirect("login.jsp");
}
if(request.getParameter("del")!=null)
{
stmt.executeUpdate("delete from scott.jobnews where id='"+request.getParameter("del")+"'");
} %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-cn">
<link rel="stylesheet" href="../inc/index.css" type="text/css">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>天天人才—>人才市場—>新聞管理</title>
</head>
<SCRIPT LANGUAGE="JavaScript">
<!--//
function check()
{
if (isNaN(go2to.page.value))
alert("請正確填寫轉到頁數!");
else if (go2to.page.value=="")
{
alert("請輸入轉到頁數!");
}
else
go2to.submit();
}
//-->
</SCRIPT>
<SCRIPT language=JavaScript src="../inc/window.js"></SCRIPT>
<body topmargin="0" leftmargin="0">
<table border="0" cellpadding="0" cellspacing="0" width="780" height="450">
<tr bgcolor="#5388C1">
<td width="778" height="14" valign="top" colspan="3"></td>
</tr>
<tr>
<td valign="top" height="424" width="176" bgcolor="#E1E1E1">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="118" background="../images/stat-bg.GIF">
<tr>
<td height="34">
<p align="center"> <a href="mnews.jsp"> 新聞管理</a>
</td>
</tr>
<tr>
<td height="29">
<p align="center"><a href="mperson.jsp">管理個人用戶</a>
</td>
</tr>
<tr>
<td height="34">
<p align="center"><a href="mcompany.jsp">管理單位用戶</a>
</td>
</tr>
<tr>
<td height="28">
<p align="center"><a href="exit.jsp">退出登錄</a>
</td>
</tr>
</table>
</center>
</div>
<p align="center"> </td>
<td valign="top" height="424" width="1" bgcolor="#5388C1"> </td>
<td valign="top" height="424" width="602">
<div align="center">
<center>
<%
int intPageSize;
int intRowCount;//記錄總數
int intPageCount;//總頁數
int intPage;//頁面參數
String strPage;//定義變量用來傳遞page
int i,j;
intPageSize=5;//定義每頁顯示5條記錄
strPage=request.getParameter("page");//取得當前的頁碼
if(strPage==null){//判斷初始頁面,如果沒有顯示記錄,就置為第一頁
intPage=1;
}else{
intPage=Integer.parseInt(strPage);//將strPage轉化為整數
if(intPage<1) intPage=1;
}
//ResultSet rt = stmt.executeQuery("select count(*) lcount from scott.learning");//取得記錄總數
//String sql="select count(*) from scott.learning";
String sqlname;
sqlname="select count(id) from scott.jobnews order by id desc" ;
ResultSet rt=stmt.executeQuery(sqlname);
rt.next();
intRowCount=rt.getInt(1);//取得整數保存與intRowCount變量中
intPageCount=(intRowCount+intPageSize-1)/intPageSize;//計算出總頁數(記錄總數+每頁顯示的記錄-1)/每頁顯示的記錄)
if(intPage>intPageCount)
intPage=intPageCount;
sqlname="select * from scott.jobnews order by id desc" ;
ResultSet rs=stmt.executeQuery(sqlname);//執行sql,按照時間先后排序顯示
i=(intPage-1)*intPageSize;
if(intRowCount==0){%>
對不起,還沒有數據!
<%}else{%>
<%-- 顯示每頁的數據 (根據i的值判斷每頁的5條記錄) --%>
<table border="1" cellpadding="0" cellspacing="0" width="545" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF">
<tr>
<td height="1" colspan="4" valign="bottom" width="541"><font color="#000000"> </font></td>
</tr>
<tr>
<td width="541" height="6" colspan="4" valign="bottom">
<font color="#000000">共有[<font color="#ff0000"><%=intRowCount%></font>]條新聞
以下是[<font color="red">1~<%=intRowCount%></font>]條</font></td>
</tr>
<tr>
<td width="541" height="7" colspan="4" valign="bottom"></td>
</tr>
<tr>
<td width="541" height="6" colspan="4" valign="bottom">
<% for(j=0;j<i;j++)
rs.next();
%>
<%-- 設置intPage參數 --%>
<FORM action=index.jsp method=POST>
<p align='center' vAlign='bottom'>
第<%=intPage%>頁 共<%=intPageCount%>頁
<%if(intPage<intPageCount){%>
<a href="index.jsp?page=<%=intPage+1%>">下一頁</a>
<%}%>
<%if(intPage>1){%>
<a href="index.jsp?page=<%=intPage-1%>">上一頁</a>
<%}%>
</form>
</td>
</tr>
</form>
<%}%>
<tr>
<td height="3" valign="top" colspan="4" bgcolor="#000000" width="541">
</td>
</tr>
</center>
<tr>
<td width="45" height="18" bgcolor="#EBEEF3" valign="bottom">
<p align="center">NewsID</p>
</td>
<center>
<td width="279" height="18" bgcolor="#EBEEF3" valign="bottom"> 標
題</td>
<td height="18" bgcolor="#EBEEF3" valign="bottom" width="134"><p align="center">發布日期</p></td>
<td height="18" bgcolor="#EBEEF3" valign="bottom" width="77">
<p align="center">- 刪除 -</td>
</tr>
<%
i=0;
while(i<intPageSize && rs.next()){
%>
<tr>
<td width="45" height="18" bgcolor="#EBEEF3" valign="bottom">
<p align="center"><%=rs.getString("id")%></p>
</td>
<td width="279" height="18" bgcolor="#EBEEF3" valign="bottom"> <a href="javascript:openwin('../viewnews.jsp?id=<%=rs.getString("id")%>','top=20,left=360,width=410,height=350')"> <%=rs.getString("title")%></a></td>
<td width="134" height="18" bgcolor="#EBEEF3" valign="bottom"><p align="center">[<%=rs.getString("idate")%>]</p></td>
<td width="77" height="18" bgcolor="#EBEEF3" valign="bottom">
<p align="center"><font color="#000046">[</font><a href="mnews.jsp?del=<%=rs.getString("id")%>"><font color="#000046">刪除</font></a><font color="#000046">]</font></td>
</tr>
<% i++;//通過I循環設置每頁的頁數
} %>
<tr>
<td height="3" valign="top" colspan="4" bgcolor="#000000" width="541">
</td>
</tr>
</center>
<tr>
<td height="8" valign="bottom" colspan="4" width="541">
<p align="center"><br>
<center>
[<a href="javascript:openwin('addnews.jsp','top=20,left=200,width=500,height=410')"><font color="#000060">添加新聞|NEWS</font></a>]</center>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr bgcolor="#5388C1">
<td valign="top" height="12" width="780" colspan="3"> </td>
</tr>
</table>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -