Advertisement
Guest User

Untitled

a guest
Jun 11th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2.  
  3. $dbhost = "localhost";
  4. $dbname = "checkboxlistview";
  5. $dbuser = "root";
  6. $dbpass = "";
  7.  
  8.  
  9. if(isset($_GET["email"]))
  10. {
  11. $email=$_GET['email'];
  12.  
  13. $con=mysqli_connect($dbhost,$dbuser,$dbpass,$dbname) or die('Database not connected');
  14.  
  15. $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'
  16. union
  17. select *,'false' as 'selected' from categories c where Id not in (SELECT distinct fc.categoryId FROM favouritecategories fc
  18. join categories c on c.id = fc.categoryId where fc.email = '$email')
  19. order by categoryName
  20. ";
  21.  
  22. $result = mysqli_query($con, $query) or die("Error in Selecting " . mysqli_error($connection));
  23. $temparray = array();
  24. while($row =mysqli_fetch_assoc($result))
  25. {
  26. $temparray[] = $row;
  27. }
  28.  
  29. echo json_encode($temparray);
  30. }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement