1.11M Members

insert multiple values into database

 
0
 

sir i a student of 4th year i need some help in my project i m creating a online quiz 30 question and each question have 6 options which are check boxes and question have more then 1 ans so ,i ll select more then one check box so that how can i store this 30 questions which have multiple values how i can store this values at once please help me sir please please please help me i request u all help

 
0
 

Multiple possible approaches just from top of head:

  • Single table with columns - id, question, answer A,.... answer F, correct answer (A, C, D) will require the answer string to be split into array by comma "," delimiter
  • Two tables
    Table 1 - id, question, answer A,.... answer F
    Table 2 - id, answer A(boolean).... answer F(boolean), where boolean represent if answer is true or false

Given that you are in 4th year one would presume you can think more pragmatically...

PS: I'm sure you read forum rules, but you may have missed this one Do provide evidence of having done some work yourself if posting questions from school or work assignments

 
0
 

sir actually i m nt doing my academic project just trying to make a online quiz and wht u suggested i m nt getting n this is my first page how i m retrieving my checkbox dynamically n when i m inserting that is going into diff row but i want to insert multiple answ of question into one feild and multiple ans of second into second field upto 30 question and my code is show below

<body>
         <form method="post" action="result.jsp">
<table>
<%
Class.forName("org.apache.derby.jdbc.ClientDriver").newInstance();
Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/Myfirstapp;create=true");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select * from test");
int i=1;
while(rs.next()){
%>
 <%=i%> <%=rs.getString("ques")%><br> 
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt1")%>" name="radio"/><%=rs.getString("opt1")%> <br>
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt2")%>" name="radio"/><%=rs.getString("opt2")%> <br>
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt3")%>" name="radio"/><%=rs.getString("opt3")%> <br>
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt4")%>" name="radio"/><%=rs.getString("opt4")%> <br>
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt5")%>" name="radio"/><%=rs.getString("opt5")%> <br>
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt6")%>" name="radio"/><%=rs.getString("opt6")%> <br>
<%
i++;
}
%>
<tr><td><input type="submit" value="submit"></td></tr>

n for inserting i m just using try catch in try catch connectivity n insert with prepared stmt plzz give me some suggestions how to do that

 
0
 

1) When you post any code please use code tags [code] YOUR CODE HERE [/code]
2) You better catch up on best practices of JSP database connectivity, good start point is JSP database connectivity according to Model View Controller (MVC) Model 2
3) Do not use "leet", "txt" or "chatroom" speak, use proper English, who is supposed to decode all your "u, n, plzz". If you can't be bothered to write properly why should I help you at all

 
0
 

k sir i will from next time i will remember it and sir any suggestion

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article