Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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');
- $query = "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
- ";
- $result = mysqli_query($con, $query) or die("Error in Selecting " . mysqli_error($connection));
- $temparray = array();
- while($row =mysqli_fetch_assoc($result))
- {
- $temparray[] = $row;
- }
- echo json_encode($temparray);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement