Created
June 22, 2017 17:23
-
-
Save CodingTricksHub/b3f2ec020d72584b6f0d630b6022a8ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$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"]) ) | |
{ | |
$email=$_POST["email"]; | |
$categoryid=$_POST["favouriteCategories"]; | |
$cat_ids=(explode(",",$categoryid)); | |
$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