jsp文章內容管理與刪除代碼
<br />
需求資訊管理
<hr color="#0099FF" size="1" />
<%
String op;
String delID = request.getParameter("ID");
op = request.getParameter("op");
if(op==null){
op = "my";
}
if (request.getParameter("submitedit") !=null){
String namea=new String(request.getParameter("name").getBytes("iso-8859-1"));
String notea=new String(request.getParameter("note").getBytes("iso-8859-1"));
String linka=new String(request.getParameter("link").getBytes("iso-8859-1"));
String pica=new String(request.getParameter("img").getBytes("iso-8859-1"));
Statement stmt_ADD=conn.createStatement();
stmt_ADD.executeUpdate("Update hl_links Set Name='"+namea+"',Noten='"+notea+"',Link='"+linka+"',pic='"+pica+"' where ID="+delID);
stmt_ADD.close();
out.print("<script type="text/javascript"> alert("您的設定已成功!"); window.location.href='xq_manage.jsp'; </script>");
return ;
}
if (op.equals("del") && delID!=null){
Statement stmt_ChannelDEL=conn.createStatement();
String Sql="delete from hl_msg where ID="+delID;
int shan=stmt_ChannelDEL.executeUpdate(Sql);
if (shan>0){
out.print("<script type="text/javascript"> alert("已成功刪除!"); window.location.href='xq_manage.jsp'; </script>");
}
stmt_ChannelDEL.close();
return ;
}
if (op.equals("look") && delID!=null){
Statement stmte=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
String Sqle="Select * from hl_msg where ID="+delID;
ResultSet Rse=stmte.executeQuery(Sqle);
if(Rse.next()) {
%>
<table width="80%" height="156" border="1" align="center" bordercolor="#d5d3d4" style=" margin-top:10px;BORDER-COLLAPSE: collapse;" cellspacing="0" cellpadding="0">
<tr>
<td width="87" align="right" bgcolor="#F3F3F3">需求產品:</td>
<td width="274" height="32" align="left" bgcolor="#F3F3F3" class="f-12-red"><span >
<%=Rse.getString("ssname")%></span> — <span >
<%=Rse.getString("product")%>
</span></td>
</tr>
<tr>
<td width="87" align="right" >需求量:</td>
<td height="32" align="left" >
<%=Rse.getString("xq")%></td>
</tr>
<tr>
<td width="87" align="right" bgcolor="#F3F3F3" >連絡人:</td>
<td height="32" align="left" bgcolor="#F3F3F3" >
<%=Rse.getString("name")%></td>
</tr>
<tr>
<td width="87" align="right" >聯絡電話:</td>
<td height="32" align="left" >
<%=Rse.getString("tel")%></td>
</tr>
<tr>
<td width="87" align="right" bgcolor="#F3F3F3" >聯絡地址:</td>
<td height="32" align="left" bgcolor="#F3F3F3" >
<%=Rse.getString("address")%>
</label></td>
</tr>
<tr>
<td width="87" height="58" align="right" >簡要說明:</td>
<td align="left" ><label>
<%=Rse.getString("resumes")%>
</label></td>
</tr>
<tr>
<td style="padding-left:260px" height="58" colspan="2" bgcolor="#F3F3F3">
<a href="javascript:history.go(-1);">返回</a> <A href="xq_manage.jsp?ID=<%=Rse.getInt("Id")%>&op=del">刪除</a>
</td>
</tr>
</table>
<%
}
Rse.close();
stmte.close();
return ;
}
if (op.equals("add")){
%>
<form name="form1" method="post" action="">
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#ECF5FF">
<tr >
<td width="21%" height="30" align="center" bgcolor="#ECF5FF"> 網站名稱</td>
<td height="30" colspan="2" bgcolor="#ECF5FF">
<input type="text" name="name" size="35" maxlength="40"> </td>
</tr>
<tr>
<td height="30" align="center" bgcolor="#ECF5FF">網站介紹</td>
<td height="30" colspan="2" bgcolor="#ECF5FF">
<input type="text" name="note" size="50" maxlength="120"> </td>
</tr>
<tr>
<td height="30" align="center" bgcolor="#ECF5FF"> 串連地址</td>
<td height="30" colspan="2" bgcolor="#ECF5FF">
<input type="text" name="link" size="40" maxlength="50" value="http://"> </td>
</tr>
<tr bgcolor="#BBDAFF">
<td height="36" align="center" bgcolor="#ECF5FF">相關圖片:</td>
<td width="22%" height="36" bgcolor="#ECF5FF"><input name="img" type="text" size="20"> </td>
<td width="57%" align="left" valign="center" bgcolor="#ECF5FF"><iframe style="top:2px" name="ad" src="../upload.htm" frameborder=0 scrolling=no width="100%" height="30"> </iframe></td>
</tr>
<tr align="center" bgcolor="#A4B6D7">
<td height="30" colspan="3" bgcolor="#ECF5FF">
<input type="hidden" name="addnew" value="true" />
<input type="submit" name="Submit" class="Submit" value="提交"> <input type="reset" name="Submit2" class="Submit" value="重設"> </td>
</tr>
</table>
</form>
<%
return ;
}
%>
<div align="center">
<table width="600" border="0" cellspacing="1" bgcolor="#CCCCCC">
<tr height="20" bgcolor="#FFFFFF">
<td width="100" >連絡人</td>
<td width="100" >聯絡電話</td>
<td width="100" >需要產品</td>
<td >需求量</td>
<td width="100" >管 理</td>
</tr>
<%
int pageSize=10; //每頁顯示的文章數
int showPage=1; //當前頁面顯示的頁號
int recCount=0; //ResultSet中的文章總數
int pageCount=0; //分頁後的總頁數
String toPage = request.getParameter("page");
Statement stmt3=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
String Sql3="Select * from hl_msg";
ResultSet RsF=stmt3.executeQuery(Sql3);
if(RsF.next()) {
RsF.last();
recCount=RsF.getRow();
pageCount=((recCount%pageSize)==0?(recCount/pageSize):(recCount/pageSize)+1);
if(toPage!=null)
showPage=Integer.parseInt(toPage);
RsF.absolute((showPage-1)*pageSize+1);
for(int i=1;i<=pageSize;i++){
int ID = RsF.getInt("Id");
%>
<tr bgcolor="#FFFFFF" onmouseover="this.bgColor='#f0f8ff';" onmouseout="this.bgColor='#FFFFFF';">
<td ><%=RsF.getString("name")%></td>
<td ><%=RsF.getString("tel")%></td>
<td ><%=RsF.getString("product")%></td>
<td ><%=RsF.getString("xq")%></td>
<td ><a href="xq_manage.jsp?ID=<%=ID%>&op=look">查看</a> | <a href="xq_manage.jsp?ID=<%=ID%>&op=del" onclick="return confirm('刪除後將不能恢複,你確定刪除嗎?')">刪除</a></td>
</tr>
<%
if(!RsF.next())
break;
}
}
%>
</table>
<table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center"><br/>
<a class='f-12-black'>總共 <%=recCount%> 條記錄 第<%= showPage %>/<%=pageCount%>頁</a> <% if (showPage>1) { %><a class='f-12-black' href='xq_manage.jsp?page=<%= showPage-1 %>'>上一頁</a> <% } if (showPage<pageCount) { %> <a class='f-12-black' href='xq_manage.jsp?page=<%= showPage+1 %>'>下一頁</a> <% } %> <a class='f-12-black' href='xq_manage.jsp?page=<%=pageCount %>'>最後一頁</a> <a class='f-12-black'>去第<select name='sel_page' onChange='javascript:location=this.options[this.selectedIndex].value;'><% for(int i=1;i<=pageCount;i++){ %> <option value='xq_manage.jsp?page=<%=i %>' <% if(i==showPage){ %>selected <% } %>><%=i %></option><% } %></select>頁</a>
</div></td>
</tr>
</table>
</div>
<%
RsF.close();
stmt3.close();
conn.close();
%>
</body>
</html>