<%@ page language="java" import="java.util.*" import ="java.sql.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>投票系统</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<style>
#container {
text-align: center;
height: auto;
padding: 15px;
}
#yangshi{
margin:50px;
height:600px;
box-shadow:5px 5px 70px #0F0F0F;
}
#child-container {
margin:25px;
text-align: left;
display: inline-block;
line-height: 30px; //间距
}
td{font-size:22px;}
</style>
<body>
<div id="container" >
<div id="yangshi">
<table align="center">
<p style="background-color:#00C5CD;color:white;text-align: center;">
<font size="15" face="楷体"> 投票系统<br></font></p>
<div id="child-container" >
<tr bgcolor = "yellow" size="10" align="center">
<td >编号</td>
<td>姓名</td>
<td>得票数</td>
<td>投票</td>
</tr>
<%
String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
String url = "jdbc:sqlserver://localhost:1433;DatabaseName=toupiao";
String sql = "select * from Dvote";
Class.forName(driverName);
conn = DriverManager.getConnection(url, "test", "123456");
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
String id=rs.getString("id");
String name=rs.getString("name");
int vote = rs.getInt("vote");
%>
<tr bgcolor='pink'>
<td align="center"><%=id %></td>
<td align="center"><%=name %></td>
<td><img src='red.jpg' width="<%=vote %>" height=10><%=vote %></td>
<td><a href='vote.jsp?id=<%=id %>'>投票</a></td></tr>
<%
}
stmt.close();
conn.close();
%>
</table>
</div>
</div>
</div>
</body>
<html>