
hi,, plz help me by providing the code for displaying SELECTED columns from mysql table which are given dynamically through checkboxes.... i created dynamic page to display columns in the table but how to handle them and display ...here is the code <%-- Document : columns Created on : Mar 1, 2012, 12:17:14 AM Author : cc --%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" import="java.sql.*"%>
<html>
<head><title>Read from mySQL Database</title>
<link rel="html" href="css.html" type="text/css">
</head>
<body>
<p align="center"><b>Fields In the table.</b><br> </p>
<div align="center" width="85%">
<a id="currenttab" href="columns.jsp">columns</a>
<a href="delete.jsp">delete</a>
<center>
<table border="1" borderColor="#ffe9bf" cellPadding="0" cellSpacing="0" width="658" height="63">
<tbody>
<%
String DRIVER = "com.mysql.jdbc.Driver";
Class.forName(DRIVER).newInstance();
Connection con=null;
ResultSet rst=null;
Statement stmt=null;
String temp=null;
try{
String url="jdbc:mysql://localhost:3306/test";
int i=1;
con=DriverManager.getConnection(url,"root","root");
stmt=con.createStatement();
rst=stmt.executeQuery("select column_name from information_schema.columns where table_name='sam'");
while(rst.next()){
if (i==(i/2)*2){
%>
<tr>
<td bgColor="#ffff98" vAlign="top" width="47" align="center" height="19"><input type="checkbox" name="column"><%=rst.getString(1)%>.</td>
<%
}else{
%>
<tr>
<td bgColor="#ffcc68" vAlign="top" width="47" align="center" height="19"><input type="checkbox" name="column"><%=rst.getString(1)%>.</td>
</tr>
<% }
i++;
}
rst.close();
stmt.close();
con.close();
}catch(Exception e){
System.out.println(e.getMessage());
}
%>
</tbody>
</table>
</center>
</div>
</body>
</html>
thanks in advance......
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.