help with yes/no radio button for multiple questions pull from database

Posted by Darlene on Programmers See other posts from Programmers or by Darlene
Published on 2012-11-04T22:46:47Z Indexed on 2012/11/04 23:16 UTC
Read the original article Hit count: 206

Filed under:

hey guys i need a little help with this questionaire form.

The tables currently using are:

  user
    userid| username

answers
aswerid|quesid|ans|userid|date

ques
quesid|ques 

The form below is what im using however i'm gettin errors for radio button.... could anyone offer advice?

 $query = mysql_query("SELECT * FROM ques", $con) 
                            or die("Cannot Access tblprequeations From Server");
        echo"<div id='quesform' class='quesform'>";     
    echo"<form name='QForm' method='post' action='answers.php' onsubmit='return validateQForm(this);'>";

    echo"<p>";
        while($row = mysql_fetch_array($query))
        {
        echo"<p>";

            echo"<label>".$row['quesid']."</label>&nbsp; &nbsp;";
            echo"<label>".$row['ques']."</label>&nbsp; &nbsp;";
    echo"<input type='radio' name='ans' value='yes' if (isset($_POST['ans']) && $_POST['ans'] == 'yes') echo'checked'/>";
    echo"<input type='radio' name='ans' value='no' if (isset($_POST['ans']) && $_POST['ans'] == 'no') echo'checked'/>";

        echo"</p>";
        }
        echo"</p>";

© Programmers or respective owner

Related posts about php