rich11 Posted October 23, 2007 Share Posted October 23, 2007 Hello, I have a survey that i am doing, and one of the questions is pick your top two questions out of six answers. When I submit the form how do I know what check boxes they click and how do I know if they clicked three instead of two?? Thank you... here is my code for the question <tr> <td width="33%"><font face="Arial"> <input type="checkbox" name="C6" value="ON"><font size="2"> Hospital newsletter</font></font></td> </tr> <tr> <td width="33%"><font face="Arial"> <input type="checkbox" name="C7" value="ON"><font size="2"> Posters/Tent Cards</font></font></td> </tr> <tr> <td width="33%"><font face="Arial"> <input type="checkbox" name="C8" value="ON"><font size="2"> Awareness Website</font></font></td> </tr> <tr> <td width="33%"><font face="Arial"> <input type="checkbox" name="C9" value="ON"><font size="2"> Energy Newsletter</font></font></td> </tr> <tr> <td width="33%"><font face="Arial"> <input type="checkbox" name="C10" value="ON"><font size="2"> Displays</font></font></td> </tr> <tr> <td width="33%"><font face="Arial"> <input type="checkbox" name="C11" value="ON"><font size="2"> Intranet</font></font></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/74457-form-checkboxes-inserting-into-a-database/ Share on other sites More sharing options...
only one Posted October 23, 2007 Share Posted October 23, 2007 do something like: if(isset($_POST['C6'])) { $checboxes_set + 1; } if(isset($_POST['C7'])) { $checboxes_set + 1; } if(isset($_POST['C8'])) { $checboxes_set + 1; } if(isset($_POST['C9'])) { $checboxes_set + 1; } if(isset($_POST['C10'])) { $checboxes_set + 1; } if(isset($_POST['C11'])) { $checboxes_set + 1; } echo "ammount of echboxes set: $cechkboxes_set"; Quote Link to comment https://forums.phpfreaks.com/topic/74457-form-checkboxes-inserting-into-a-database/#findComment-376202 Share on other sites More sharing options...
rich11 Posted October 23, 2007 Author Share Posted October 23, 2007 I changed the code a bit.. but mostly the code you gave me... but it won't print anything out... the $total variable won't display. did I mess upo the code?? Rich if(isset($_POST["C1"])) { $total + 1; } if(isset($_POST["C2"])) { $total + 1; } if(isset($_POST["C3"])) { $total + 1; } if(isset($_POST["C4"])) { $total + 1; } echo "<br>"; echo "<br>"; echo "<br>"; echo "<br>"; echo "$total"; Quote Link to comment https://forums.phpfreaks.com/topic/74457-form-checkboxes-inserting-into-a-database/#findComment-376224 Share on other sites More sharing options...
otuatail Posted October 23, 2007 Share Posted October 23, 2007 Quote in wrong place echo "ammount of echboxes set: " . $cechkboxes_set; Quote Link to comment https://forums.phpfreaks.com/topic/74457-form-checkboxes-inserting-into-a-database/#findComment-376234 Share on other sites More sharing options...
rich11 Posted October 23, 2007 Author Share Posted October 23, 2007 Ok..... maybe i asked the wrong question. I want to take each text box that was checked, add each value of the textbox together in one string varaible seperated by a comma. Once I have that string variable I am going to insert it into a database field. Thx, Rich Quote Link to comment https://forums.phpfreaks.com/topic/74457-form-checkboxes-inserting-into-a-database/#findComment-376238 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.