I have 5 checkboxes in HTML page and i want to save the value of checked checkbox into mysql using PHP but when i save the form in database the value of checkbox is 1 while the value of checkbox is a,b,c,d,e etc i used the type of checkbox field as text but it saves 1.
Here is my code
The php code is
Here is my code
Code:
<input type="checkbox" name="option[]" value="a"/> <input type="checkbox" name="option[]" value="b"/> <input type="checkbox" name="option[]" value="c"/> <input type="checkbox" name="option[]" value="d"/> <input type="checkbox" name="option[]" value="e"/> <input type="submit" name="submit" value="save" />
Code:
echo"<br />";
if(isset($_POST['submit']))
{
for ($i=0; $i<count($_POST['option']);$i++) {
$i = $_POST['option'][$i];
echo "the check box selected is $i";
echo"<br />";
}
}
$query3="INSERT INTO solution VALUES('$i','$question_id')";
$result3=mysql_query($query3) or die(mysql_error());
Comment