at last i got the checkboxes to work and add to database but the only this i need advice on if i refresh the page the selected items disappear how can i solve this the
php file is as follows
<?php
include("config/db_connect.php");
extract($_POST);
$check_exist_qry="select * from interests";
$run_qry=mysqli_query($conn,$check_exist_qry);
$total_found=mysqli_num_rows($run_qry);
if($total_found >0)
{
$my_value=mysqli_fetch_assoc($run_qry);
$my_stored_interests=explode(',',$my_value['interest_name']);
}
if(isset($submit))
{
$all_interests_value = implode(",",$_POST['interests']);
if($total_found >0)
{
//update
$upd_qry="UPDATE interests SET interest_name='".$all_interests_value."'";
mysqli_query($conn,$upd_qry);
}
else
{
//insert
$ins_qry="INSERT INTO interests(interest_name) VALUES('".$all_interests_value."')";
mysqli_query($conn,$ins_qry);
}
}
if (!empty($_POST['submit'])) {
echo "<ul>";
foreach ($_POST['interests'] as $value) {
echo "<li>$value</li>";
}
echo "</ul>";
} else {
echo "none";
}
?>