954,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

insert multiple values into database

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

shadab550
Newbie Poster
3 posts since Feb 2012
Reputation Points: 10
Solved Threads: 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

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

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")%> 
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt1")%>" name="radio"/><%=rs.getString("opt1")%> 
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt2")%>" name="radio"/><%=rs.getString("opt2")%> 
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt3")%>" name="radio"/><%=rs.getString("opt3")%> 
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt4")%>" name="radio"/><%=rs.getString("opt4")%> 
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt5")%>" name="radio"/><%=rs.getString("opt5")%> 
      &nbsp;<input type="checkbox" value="<%=rs.getString("opt6")%>" name="radio"/><%=rs.getString("opt6")%> 
<%
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

shadab550
Newbie Poster
3 posts since Feb 2012
Reputation Points: 10
Solved Threads: 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

peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
 

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

shadab550
Newbie Poster
3 posts since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You