Created
June 22, 2017 18:01
-
-
Save CodingTricksHub/298fa302c63eca092182d1b0fb8db1f7 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 = ""; | |
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