23
十二月

網頁程式設計12/23 程式bilist.jsp

   Posted by: admin   in 97(上)網頁程式設計

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<%@ page language="java" contentType="text/html; charset=BIG5"  pageEncoding="BIG5"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 
<head>
<meta http-equiv="Content-Language" content="zh-tw">
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<title>2008恐龍展報名資料</title>
</head>
 
<body>
 
<p>2010生姿畢業旅行投票資料</p>
<%
  Class.forName("com.mysql.jdbc.Driver");
  String url = "jdbc:mysql://localhost:3306/dino";
  Connection con = DriverManager.getConnection( url,"bioinfo", "6193");
  Statement stmt = con.createStatement();
  String query="SELECT SID, SName, SLoc, SComment, SDate FROM vote ORDER BY SDate";
  stmt.execute(query);
  ResultSet rs = stmt.getResultSet();
  int num_rows=rs.getMetaData().getColumnCount();
%>
<p> <%= num_rows %> 筆投票資料</p>
 
<table border="1" width="100%" id="table1">
	<tr>
		<td>學號</td>
		<td>姓名</td>
		<td>選擇地點</td>
		<td>投票時間</td>
		<td>意見</td>
	</tr>
<% 
while (rs.next()) {
	String SID      = new String(rs.getString(1).getBytes("ISO-8859-1"), "Big5");
	String SName    = new String(rs.getString(2).getBytes("ISO-8859-1"), "Big5");
	String SLoc     = new String(rs.getString(3).getBytes("ISO-8859-1"), "Big5");
	Timestamp SDate = rs.getTimestamp(5);
	String SComment = new String(rs.getString(4).getBytes("ISO-8859-1"), "Big5");
 
%>
	<tr>
		<td><%=SID %></td>
		<td><%=SName %></td>
		<td><%=SLoc %></td>
		<td><%=SDate %></td>
		<td><%=SComment %>_</td>
	</tr>
<% 
}
%>
</table>
<hr>
投票結果
<table border="1" width="100%" id="table2">
	<tr>
<%
rs.close(); 
query="SELECT Count(SLoc) AS SNum, SLoc FROM vote GROUP BY SLoc";
stmt.execute(query);
rs = stmt.getResultSet();
 
while (rs.next()) {
	int SNum   = rs.getInt(1);
	String SLoc = new String(rs.getString(2).getBytes("ISO-8859-1"), "Big5");
 
%>
		<td><%=SLoc %></td>
		<td><%=SNum %></td>	
<% 
}
con.close();
%>
</tr>
</table>
</body>
</html>

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

This entry was posted on 星期二, 十二月 23rd, 2008 at 16:12:45 and is filed under 97(上)網頁程式設計. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Trackback/Ping

  1. eric    七月 30 2014 / 6下午:

    workin@pastors.minoan” rel=”nofollow”>.…

    tnx for info….

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment