M
mak
Hi Friends,
I'm facing a serius problem...in 2 days i have to submit my project
and i'm stuck here..please help me...
I'm getting some values from the database from one table say roll_no
on one page....and then on that page i'm putting some values in front
of that roll_no.
Now I want to store the all data in a another table..
P.S. roll no. are not fixed and that is it can any thing from 1 - 60
here is my code.
second page from where i'm inserting.
please help me......
I'm facing a serius problem...in 2 days i have to submit my project
and i'm stuck here..please help me...
I'm getting some values from the database from one table say roll_no
on one page....and then on that page i'm putting some values in front
of that roll_no.
Now I want to store the all data in a another table..
P.S. roll no. are not fixed and that is it can any thing from 1 - 60
here is my code.
Java:
<select size="1" name="subject" style="font-family: Arial; font-size:
10px; color:#0B333C"></select>
<--some value -->
<select size="1" name="month" style="font-family: Arial; font-size:
10px; color:#0B333C"></select>
<--some value-->
<select size="1" name="year" style="font-family: Arial; font-size:
10px; color:#0B333C"></select></tr>
<tr>
<td><input type="submit" value="SUBMIT" name="action"/>
<table width="800" border="4" cellpadding="1" cellspacing="1">
<td>
<table width="800" border="2" bordercolor="#FFFFFF"
cellpadding="0" cellspacing="0">
<tr> <td align="right">
</tr>
<td>
<%! String stu_roll;%>
<%
String getsub1 = request.getParameter("subject");
String getmonth = request.getParameter("month");
String getyear = request.getParameter("year");
%>
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:lala");
Statement stmt = con.createStatement();
String str1 = "select roll_no from student where sem_id = (select
sem_id from subject where course_id ='bsc_it' and sub_id =
'"+getsub1+"')";
ResultSet rs = stmt.executeQuery(str1);
%>
<table align="center" width="" cellpadding="0" cellspacing="0"
border="1" cellspacing="1" cellpadding="1">
<tr>
<td><input type="text" value="Total Lecture" readonly=""/></td>
<td><input type="text" name="total_att" maxlength="2"></td>
</tr>
<tr>
<td><input type="text" value="Student roll no." readonly="" /></
td>
</tr>
<%
int no = 0;
while(rs.next())
{
stu_roll = rs.getString("roll_no");
no = no + 1;
%>
<tr bordercolor="#CC3366">
<td>
<input type="text" name="roll<%=no %>" value="<%= stu_roll %>"
readonly=""/>
</td>
<td align="center" style="color:#0052A4 ">:</td>
<td>
<input type="text" name="att<%=no %>" />
<input type="hidden" name="no" value="<%=no %>" />
</td>
</tr>
<%
}
%>
Java:
<%!
int no1 = request.getParameter("no");
int i;
%>
<%
for(i=1;i<no1;i++)
{
%>
<%
String getsub1 = request.getParameter("subject");
String getmonth = request.getParameter("month");
String getyear = request.getParameter("year");
String getatt = request.getParameter("att"+i);
String stu_roll = request.getParameter("roll"+i);
%>
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con =
DriverManager.getConnection("jdbc:odbc:lala");
PreparedStatement ps=con.prepareStatement("insert into
attendance values(?,?,?,?,?,?)");
ps.setString(1,stu_roll);
ps.setString(2,getsub1);
ps.setString(3,getmonth);
ps.setString(4,getyear);
ps.setString(5,getatt);
ps.setString(6,"10");
ps.executeUpdate();
%>