Jump to content

[SOLVED] Problem with radio groups


designergav

Recommended Posts

Hi,

No matter what I do My radio buttons always have the value 'YES' even if I select 'NO'. I have 4 questions with YES/NO answers, users check a radio box and submit the answers to a db.

 

These are the butttons:

Did you find this useful? <label><input type="radio" name="Q1" value="yes"/>yes</label>   <label><input type="radio" name="Q1" value="no"/>no</label>
Would you be able to use this video in your sales cycle? <label><input type="radio" name="Q2" value="yes"/>yes</label>   <label><input type="radio" name="Q2" value="no"/>no</label>
Do you find multimedia references like videos useful? <label><input type="radio" name="Q3" value="yes"/>yes</label>   <label><input type="radio" name="Q3" value="no"/>no</label>
Would you like to see more videos similar to the B-Source one? <label><input type="radio" name="Q4" value="yes"/>yes</label>   <label><input type="radio" name="Q4" value="no"/>no</label>

 

And this checks the values:

if (isset($_POST['Submit'])) { //open everything
	$Q1=$_POST['Q1'] 
	$Q2=$_POST['Q2'] 
	$Q3=$_POST['Q3'] 
	$Q4=$_POST['Q4'] 		
$thanks="<font color=\"#469013\" face=\"arial, helvetica\" size=\"3\"><b>Thank you for leaving feeedback</b></font>";

// QUESTION 1
if ($Q1='yes') {
	$insertQ1 = "UPDATE videofeedback SET yes=yes+1 WHERE ID='1' lIMIT 1";
        mysql_query($insertQ1);
	} else {
	$insertQ1b = "UPDATE videofeedback SET no=no+1 WHERE ID='1' lIMIT 1";
        mysql_query($insertQ1b);
	} 
// QUESTION 2
if ($Q2="yes") {
	$insertQ2 = "UPDATE videofeedback SET yes=yes+1 WHERE ID='2' lIMIT 1";
        mysql_query($insertQ2);
	} else {
	$insertQ2b = "UPDATE videofeedback SET no=no+1 WHERE ID='2' lIMIT 1";
        mysql_query($insertQ2b);
	} 
// QUESTION 3
if ($Q3="yes") {
	$insertQ3 = "UPDATE videofeedback SET yes=yes+1 WHERE ID='3' lIMIT 1";
        mysql_query($insertQ3);
	} else {
	$insertQ3b = "UPDATE videofeedback SET no=no+1 WHERE ID='3' lIMIT 1";
        mysql_query($insertQ3b);
	} 
// QUESTION 4
if ($Q4="yes") {
	$insertQ4 = "UPDATE videofeedback SET yes=yes+1 WHERE ID='4'v";
        mysql_query($insertQ4);
	} else {
	$insertQ4b = "UPDATE videofeedback SET no=no+1 WHERE ID='4' lIMIT 1";
        mysql_query($insertQ4b);
	} 
}

Then I need to increment the db field by 1. It is a running total of answers. The fields are ID, Question, Yes, No. So line 1 would be 1, Did you find this useful?, 67, 13 (for example)

 

Can anyone help?

Link to comment
https://forums.phpfreaks.com/topic/66361-solved-problem-with-radio-groups/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.