1

在这种形式中,我可以毫无问题地构建和显示问题和答案(即我数据库中表内的值)。但是现在我如何插入选择的答案?因为我需要每行插入一个答案,并且答案在一个问题上将是多值的。

我要插入的表具有以下结构:Tbluseranswer (UserIDFKPK ,AnswerIDFKPK ,QuestionIDFK ,AnswerValue`)

 <?php
    $query_questionset= "SELECT Constructor, QuestionIDFKPK, OnPage, QuestionValue, tblquestionset.SortOrder
    FROM tblquestion, tblquestionset, tbluser
    WHERE tbluser.QuestionSetIDPK = tblquestionset.QuestionSetIDPK
    AND tblquestionset.QuestionIDFKPK = tblquestion.QuestionIDPK
    AND tbluser.UserIDPK = ".@$UserId."
    AND tblquestionset.OnPage= '".@$Screen."'
    ORDER BY tblquestionset.SortOrder";

    $QuestionSet_Constructors = mysql_query($query_questionset);


if(isset($_POST['submit'])){

//Inserts here

}

?>
<html>
<head>
</head>
<body>

<!--BUILDING QUESTIONARE -->

    <?php  while( $row_questionset=mysql_fetch_array($QuestionSet_Constructors)){?> 

            <?php $QuestionID=$row_questionset['QuestionIDFKPK'];   


                    $query_Answer="SELECT * FROM tblanswer WHERE tblanswer.QuestionIDFK = '".@$QuestionID."'";
                    $AnswersValue= mysql_query($query_Answer);

            ?>
        <?php if($row_questionset['Constructor']=="CheckBox"){?>


                <!--SPACE-->
                <div>
                <label class="desc" >
                </label>
                </div>
                <!--/SPACE-->

                        <!--CHECK BOX-->    

                        <div>
                        <label class="desc" name="question" value= "<?php $row_questionset['QuestionIDFKPK'];?>" >
                        <?php echo $row_questionset['QuestionValue']; ?>

                        </label>
                        </div>

                            <!--SPACE-->
                            <div>
                            <label class="desc" >
                            </label>
                            </div>
                            <!--/SPACE-->

                                <fieldset class="checkboxes">
                                <?php while ($row_Answer=mysql_fetch_array($AnswersValue)){ ?>  
                                    <label class="label_check" >
                                    <input name="samplecheckbox"  value="<?= $row_Answer['AnswerValue']; ?>" type="checkbox" />




                                    <?php echo $row_Answer['AnswerValue']; ?>   
                                    </label>    


                                <?php }  ?> 
                                </fieldset>

                        <!--/CHECK BOX-->   

    <!--RADIO BUTTON--> 

                        <div>
                            <label class="desc"name="question" value=" <?php $row_questionset['QuestionIDFKPK'];?>">
                            <?php echo $row_questionset['QuestionValue']; ?>

                            </label>
                        </div>
                            <?php while ($row_Answer=mysql_fetch_array($AnswersValue)){ ?>  
                            <fieldset class="radios">

                                <label class="label_radio">
                                <input name="sample-radio"  value=" <?= $row_Answer['AnswerValue']; ?>" type="radio" checked />
                                <?php echo $row_Answer['AnswerValue']; ?> 
                                </label>
                                <?php   

                                <?php $AnswerId=$row_Answer['AnswerIDPK'];  ?>
                                <?php 
                            <?php }  ?>
                            </fieldset>

                    <!--RADIO BUTTON--> 

        <?php } ?>

    <?php } ?>

    <!--BUILDING QUESTIONARE -->    




<input  name="submit" type="submit"  value="Next &#8594"  >

</form>
</body>
</html>
4

0 回答 0