Hello everyone,
I'm working on adding checkboxes to the edit_profile section where members should be able choose with checkboxes the multiple options of massage techniques offered... When I checked only one, either, option 1, or option 2 or option 3 I'm able to see it in the column in the correct table of mysql but when I check more then one box only the last box would insert into the column, ignoring the rest. In this case, if I check the three options, only lomi lomi would insert into the column... I hope you guys can help me. Here is the code:
// set all checkboxes to false initially
$Deeptissue="";
$Swedish="";
$Lomilomi="";
$checkbox=$_POST['typeTech'];
//if appear in the POST, they are checked, set to true
foreach($checkbox as $typeTech ) {
if($typeTech=="deeptissue")
$Deeptissue="Deep Tissue";
else if($typeTech=="swedish")
$Swedish="Swedish";
else if($typeTech=="lomilomi")
$Lomilomi="Lomi Lomi";
}
echo "Technique checked: ".$Deeptissue."<br/>\n";
echo "Tchnique checked: ".$Swedish."<br/>\n";
echo "Technique checked: ".$Lomilomi."<br/>\n";
$sql = mysql_query("INSERT INTO Members (Technique)
VALUES('$typeTech')")
or die (mysql_error());