<%@ page language=“java” contentType=“text/html; charset=UTF-8”
pageEncoding=“UTF-8”%>
<%@ page import=“java.sql.*” %>
<%!
int getNewsCount(String lx){
int returnvalue=0;
try{
Class.forName(“com.mysql.jdbc.Driver”);
Connection conn=DriverManager.getConnection(“jdbc:mysql://localhost:3306/museum?user=root&password=419111&characterEncoding=utf-8”);
Statement stmt=conn.createStatement();
String strSql;
if(lx.equals(“内容列表”)){
strSql=“select count(id) xwts from userinfo;”;
}
else
{
strSql=“select count(id) xwts from userinfo where name=’”+lx+"’;";
}
ResultSet rs=stmt.executeQuery(strSql);
if(rs.next()){
returnvalue=rs.getInt("xwts");
}
rs.close();
stmt.close();
conn.close();
}
catch(Exception ex){
}
return returnvalue;
}
%>
<%
request.setCharacterEncoding(“utf-8”);
%>
<%
String strLx=request.getParameter(“list”);
if(strLx==null) strLx=“内容列表”;
%>
<%
String strSql=“select * from userinfo”;
/* if(strLx.equals(“内容列表”)){
strSql=strSql+" order by id desc";
}
else
{
strSql=strSql+" where leixing=’"+strLx+"’ order by shijian desc";
} */
int pagesize=20;
String strPage=request.getParameter(“page”);
if(strPage==null) strPage=“0”;
int curpage=Integer.parseInt(strPage);
if(curpage<1) curpage=1;
int startRow=0;
startRow=(curpage-1)*pagesize;
int total=getNewsCount(strLx);
int totalpage=0;
if(total%pagesize==0){
totalpage=total/pagesize;
}
else
{
totalpage=total/pagesize+1;
}
if(curpage>totalpage) curpage=totalpage;
int prePage=curpage-1;
if(prePage<=0) prePage=1;
int nextPage=curpage+1;
if(nextPage>totalpage) nextPage=totalpage;
try{
Class.forName(“com.mysql.jdbc.Driver”);
Connection conn=DriverManager.getConnection(“jdbc:mysql://localhost:3306/museum?user=root&password=419111&characterEncoding=utf-8”);
Statement stmt=conn.createStatement();
strSql=strSql+" LIMIT “+startRow+”,"+pagesize+";";
ResultSet rs=stmt.executeQuery(strSql);
rs.beforeFirst();
%>
<tr >
<td style="align:center"><%=rs.getString("id") %></td>
<td>
<%=rs.getString("username") %>
</td>
<td ><%=rs.getString("password") %></td>
<td ><%=rs.getString("phone") %></td>
<td ><%=rs.getString("name") %></td>
<td ><%=rs.getString("idnumber") %></td>
<td ><%=rs.getString("email") %></td>
<td><a href="usermanagementdel.jsp?id=<%=rs.getString("id") %>" onclick="return confirm('您确定要删除吗?');">删除</a></td>
</tr>
</div>
id | 用户名 | 用户密码 | 用户电话 | 用户姓名 | 用户身份证号码 | 用户邮箱 | 信息删除 |
<%
}
%>
<%
rs.close();
stmt.close();
conn.close();
}
catch(Exception ex){
out.print(ex.getMessage());
}
%>
<div >每页<%=pagesize%>条,总共<%=totalpage%>页共<%=total%>条。
<a href="usermanagement.jsp?list=<%=strLx%>&page=1">第一页</a>
<a href="usermanagement.jsp?list=<%=strLx%>&page=<%=prePage%>">上一页</a>
<a href="usermanagement.jsp?list=<%=strLx%>&page=<%=nextPage%>">下一页</a>
<a href="usermanagement.jsp?list=<%=strLx%>&page=<%=totalpage%>">最后一页</a></div>