Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
$dbhost = "localhost";
$dbname = "checkboxlistview";
$dbuser = "root";
$dbpass = "";
$con=mysqli_connect($dbhost,$dbuser,$dbpass,$dbname) or die('Database not connected');
if(isset($_POST["email"]) && isset($_POST["favouriteCategories"]) )
$count= count($cat_ids);
$query_delete="DELETE FROM favouritecategories WHERE email ='$email'";
mysqli_query($con, $query_delete);
for ($i=0; $i < $count ; $i++)
$catid = $cat_ids[$i];
$query_insert="INSERT INTO `favouritecategories`(`email`, `categoryId`) VALUES ('$email',$catid)";
mysqli_query($con, $query_insert);
echo 'Favourite Categories Updated';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment