designergav Posted August 23, 2007 Share Posted August 23, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/66361-solved-problem-with-radio-groups/ Share on other sites More sharing options...
frost Posted August 23, 2007 Share Posted August 23, 2007 Try changing these: "if ($Q1='yes')" to if ($Q1=='yes') Quote Link to comment https://forums.phpfreaks.com/topic/66361-solved-problem-with-radio-groups/#findComment-332044 Share on other sites More sharing options...
designergav Posted August 24, 2007 Author Share Posted August 24, 2007 Wow. how embarassingly easy. I had already tried that but it looks like I only did it in one set of if statements. It works perfectly now. Thank you so much, I now have time for a cup of tea and a biscuit. Quote Link to comment https://forums.phpfreaks.com/topic/66361-solved-problem-with-radio-groups/#findComment-332821 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.