i have searched a lot, but didn't find any solution. i want to save checkbox selected options in SQL. if user selects two check boxes thay must save in MySQL with comma separated.
Kinly please help me in solving this
HTML CODE
<input name="patno" id="patno">
<input type="checkbox" name="newt[]" value="Diesel" id="type" />Diesel
<input type="checkbox" name="newt[]" value="Petrol" id="type" />Petrol
<input type="checkbox" name="newt[]" value="Electricity" id="type" />Electricity
PHP CODE
$order = "INSERT INTO tblsampo
(patno, stno, newt)
VALUES
('$smonth',
'$patno','$stno','$newt')";
$result = mysql_query($order); //order executes
if($result){
echo("<br>Input data is succeed");
} else{
echo("<br>Input data is fail");
}
?>
implodeit before storing in the database. Also, themysql_*functions are deprecated and should not be used and your checkbox elements need to have unique ids if that are going to have ids