Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
$dbhost = "localhost";
$dbname = "checkboxlistview";
$dbuser = "root";
$dbpass = "";
if(isset($_GET["email"]))
{
$email=$_GET['email'];
$con=mysqli_connect($dbhost,$dbuser,$dbpass,$dbname) or die('Database not connected');
$query1 = "select distinct fc.categoryId as 'id',c.categoryName,'true' as 'selected' FROM favouritecategories fc join categories c on c.id = fc.categoryId where fc.email = '$email'
union
select *,'false' as 'selected' from categories c where Id not in (SELECT distinct fc.categoryId FROM favouritecategories fc
join categories c on c.id = fc.categoryId where fc.email = '$email')
order by categoryName
";
$result1 = mysqli_query($con, $query1) or die("Error in Selecting " . mysqli_error($connection));
$temparray = array();
while($row =mysqli_fetch_assoc($result1))
{
$temparray[] = $row;
}
echo json_encode($temparray);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.