Jsp+mysql make a simple message board (6)

Source: Internet
Author: User
Js|mysql Webmaster Management page is established: This page can be viewed and deleted from other people's messages.
The structure is similar to board.jsp, except that a single check box is added to each message to facilitate deletion:
<title> Expert Message Board </title>
<body>
<% @page import= "java.sql.*"%>
<% @page contenttype= "text/html;charset=gb2312"%>
<% @include file= "opendata.jsp"%>
<%
int Count=0,lastp,numf,numl,prep,nextp,pageno;
if (Request.getparameter ("PageNo") ==null)
{

pageno=0;
}
Else
Pageno=integer.parseint (Request.getparameter ("PageNo"));
Sql= "SELECT * from Message";
Rs=smt.executequery (SQL);
while (Rs.next ())
count++;
lastp= (int) Math.ceil (double) COUNT/5);
if (pageno==0| | PAGENO&GT;LASTP)
PAGENO=LASTP;
numf=pageno*5-4;
numl=numf+4;
if (pageno==1)
Prep=1;
Else
Prep=pageno-1;
if (PAGENO==LASTP)
NEXTP=LASTP;
Else
nextp=pageno+1;
Sql= "SELECT * from message where ID between" +numf+ "and" +NUML;
Rs=smt.executequery (SQL);
%>
<font size=7 color=green> expert message Board </font>
<font color= #008080 > Webmaster use screen </font>
<center>
<form action=board.jsp method=post>
<table boder=0>
<tr>
<td> Current page: <font size=2 color=red><%=pageno%></font>/<font color=blue><%=lastp% ></font></td>
<td><a href=manager.jsp?pageno=<%=prep%>>[prev]</a></td>
<td><a href=manager.jsp?pageno=<%=nextp%>>[Next Page]</a></td>
<td><a href=manager.jsp?pageno=1>[First Page]</a></td>
<td><a href=manager.jsp>[last page]</a></td>
<td> Input page times <input type=text size=3 name=pageno></td>
<td><input type=submit name=send value= send out ></td>
<td><a href=password.jsp><font color=red size= "5" >
<i> Station Drill </i></font></a></td>

</tr>
</table>
</form>
<form action=delete.jsp?pageno=<%=pageno%>method=post>
<%
String Name,email,subject,time,sex,memo;
int id;
while (Rs.next ())
{
Name=rs.getstring (1);
Email=rs.getstring (2);
Subject=rs.getstring (3);
Time=rs.getstring (4);
Sex=rs.getstring (5);
Memo=rs.getstring (6);
Id=rs.getint (7);
Out.print ("<p align=left><input type=checkbox name=d" +id+ "value=del>" delete the <font color=red> "+id+" </font> ");
Out.print ("<center>");
Out.print ("<table border=1>");
Out.print ("&LT;TR&GT;&LT;TD bgcolor=yellow> name </td><td>" +name+ "</td></tr>");
Out.print ("<tr><td bgcolor=yellow>e-mail</td><td>" +email+ "</td></tr>");
Out.print ("<tr><td bgcolor=yellow> time </td><td>" +time+ "</td></tr>");
Out.print ("<tr><td bgcolor=yellow> theme </td><td>" +subject+ "</td></tr>");
Out.print ("&LT;TR&GT;&LT;TD valign=top bgcolor=yellow> message </td><td> +memo+" </td></tr> ");
Out.print ("</table></p>");


}
%>
<input type=submit name=send value= OK delete >
<input type=reset value= re-select >
</form>
<center>
<a href=message.html> I want to leave a message </a>
<a href=manager.jsp> View Message </a>
</body>
And the following is the DELETE.JSP program:
<%
String Para,value;
int pageno,numf,numl;
if (Request.getparameter ("PageNo") ==null)
pageno=0;
Else
Pageno=integer.parseint (Request.getparameter ("PageNo"));
numf=pageno*5-4;
numl=numf+4;
for (int i=numf;i<=numl;i++)
{
Para= "D" +string.valueof (i);
Value=request.getparameter (para);
if (value!=null)
{
Sql= "Delete from the message where id=" +i;
Smt.executeupdate (SQL);
}
}
sql= "ALTER TABLE message drop ID";
Smt.executeupdate (SQL);
sql= "ALTER TABLE message add ID int auto_increment primary key";
Smt.executeupdate (SQL);
Response.sendredirect ("manager.jsp");

%>
All right, all the code is complete; you can try it:




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.