<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.sql.*"%>
<html>
<head>
<title>Row to Form</title>
<script language="javascript" src="../../prototype.js"></script>
<script language="javascript" src="../../sarissa.js"></script>
<script language="javascript" src="InlineEditing.js"></script>
<link type="text/css" rel="stylesheet" href="Presidents.css"/>
</head>

<body>
<form onSubmit="return false">
<%
	Connection conn = null;
	PreparedStatement stmt = null;
	ResultSet rs = null;
	try
	{
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		conn = DriverManager.getConnection("jdbc:odbc:Presidents");
		
		String sql = "SELECT PresidentID, FirstName, LastName, Bio FROM Presidents";
		stmt = conn.prepareStatement(sql);
		
		rs = stmt.executeQuery();
		out.write("<h1>Presidents</h1>");
		out.write("<table cellpadding='2' cellspacing='0'>");
		while (rs.next()) 
		{
			out.write("<tr id='" + rs.getString("PresidentID") + "'>");
			out.write("<td onclick='Cell2Form(this)' title='FirstName'>" + rs.getString("FirstName") + "</td>");
			out.write("<td onclick='Cell2Form(this)' title='LastName'>" + rs.getString("LastName") + "</td>");
			out.write("<td onclick='Cell2Form(this)' title='Bio'>");
			out.write(rs.getString("Bio"));
			out.write("</td>");
			out.write("</tr>");
		}
		out.write("</table>");
	}
	catch(Exception e)
	{
		out.write("failed: " + e.toString());
	}
	finally 
	{
		if (rs != null) rs.close();
		if (stmt != null) stmt.close();
		if (conn != null) conn.close();
	}
%>
</form>
</body>
</html>