how do i insert into database.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mak1084
    New Member
    • Jul 2007
    • 44

    how do i insert into database.

    i'm creating a an web application in which a user after selecting the categories he gets all the student info who has taken that subject.

    my problem is i'm able to get the multiple student with the text box where a user can put up his monthly attendance. how do i insert the info in database...

    the snapshot of the code is here...
    here I'm getting the roll no. along with the text box..

    [CODE=java]
    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.executeQue ry(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>
    <% while(rs.next() )
    {
    %>

    <%
    stu_roll = rs.getString("r oll_no");
    %>
    <tr bordercolor="#C C3366">
    <td>
    <%
    out.println(stu _roll);
    %>
    </td>
    <td>
    <input type="text" name="att" />
    </td>
    </tr>&nbsp;



    <%
    }

    con.close();
    }
    catch(SQLExcept ion e)
    {
    out.println("Ex ception in SQL" + e);
    }
    %>[/CODE]
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Greetings!

    You have select roll_no from, you need insert roll_no, thisandthat, thatandtheother , into YourTabe values("yourfiledname 1,yourfiedname2 , etc...)

    thisandthat, thatandtheother , are other fields with data your users may need to access, to add to your db back-end.

    Thank you for posting your code:-)

    Dököll
    Last edited by Dököll; Dec 8 '08, 05:45 AM. Reason: added remark...

    Comment

    Working...