php - How to insert multiple choice survey answers into database? -


I am creating a site where the user can reply to the survey, my code looks like this (answering.php):

  & lt ;? Php include_once 'init / init.funcs.php'; $ _SESSION ['pollen'] = (int) $ _GET ['pollen']; $ Questions = array (); If ($! Session ['reply'])) {$ result = mysql_query (select from 'katse_kysimused where kysimustik_id =' '. $ _SESSION [' pollid '].' ''); While ($ row $ [_SESSION] [$ questions [] = $ row ['kysimus'];} $ _SESSION ['answer'] ['question'] = $ question; $ _SESSION ['answer'] ['index' ] = 0;} $ X = $ _SESSION ['Reply'] ['Index']; $ result3 = mysql_query (Select from 'tyyp_id katse_kysimused where kysimus =' '. $ _SESSION [' answer '] [' question '] [$ x]. '' '); $ type = mysql_result ($ result 3, 0); if ($ type ==' 3 ') {echo "& lt; Meta http-equiv = 'Refresh' content = '0; Url = http: //localhost/Praks/valikvastustega_kysimusele_vastamine.php'> "; $ answer = $ _POST ['answer'];} if ($ type == '1') {echo"   

And I have another code, which is if the question type is more than one answer question (if $ type == '3') (valikvastustega_kysimusele_vastamine.php): & lt ;? Php include_once 'init / init.funcs.php'; $ X = $ _SESSION ['Reply'] ['Index']; Transcription $ _SESSION ['answer'] ['question'] [$ x-1]; $ Result4 = mysql_query (select from 'Kasiss_ range) kysimus_id where kysimus =' '. $ _SESSION [' answer '] [' question '] [$ x-1].' '' '); $ Question_id = mysql_result ($ 4 results, 0); $ Result5 = mysql_query (Select 'katse_valik_vastused from where kysimus_id =' '. $ Question_id.' ''); If ($ result5 === incorrect) {dead (mysql_error ()); } While ($ line = mysql_fetch_assoc ($ result5)) {$ option [] = $ line ['vasuts']; } // foreach ($ option = option => $ option_value) {// echo $ option_value; $ Counts = count ($ option); ? & Gt; & Lt; Html & gt; & Lt; Br> & Lt; Form method = "post" action = "answering.php" & gt; & Lt ;? Php foreach ($ option = option => $ option_value) {? & Gt; & Lt; Input type = "radio" name = "& lt;? = $ Option;? & Gt;" & Gt; & Lt ;? Php echo $ option_value? & Gt; & Lt; Br> & Lt ;? Php}? & Gt; & Lt; Input name = "submit" type = "submit" value = "request" & gt; & Lt; / Form & gt;

Everything works fine now and what I want to do is insert the answer into the next database. What should I write in my code to do this work? Right now it works only with text queries.

OK, in one sense it may appear: Answer (question_id *, answer_id *, answer)

Where * = (primary component of the component)

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -