Advertisement
Guest User

Untitled

a guest
Aug 28th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. <?php
  2. require_once('config.php');
  3. require_once 'classes/BD.class.php';
  4. BD::conn();
  5. if(isset($_POST['user']) && $_POST['user'] != ""){
  6. $user = (int)$_POST['user'];
  7. $searchPhotos = BD::conn()->prepare("SELECT * FROM `photos` WHERE `id_user` = ? ORDER BY `id` DESC");
  8. $searchPhotos->execute(array($user));
  9. $resultPhotos = $searchPhotos->rowCount();
  10.  
  11. $searchQtdFollowers = BD::conn()->prepare("SELECT id FROM `follows` WHERE `user` = ?");
  12. $searchQtdFollowers->execute(array($user));
  13. $resultFollowers = $searchQtdFollowers->rowCount();
  14.  
  15. $searchQtdFollowing = BD::conn()->prepare("SELECT id FROM `follows` WHERE `follower` = ?");
  16. $searchQtdFollowing->execute(array($user));
  17. $resultFollowing = $searchQtdFollowing->rowCount();
  18.  
  19. $array = array(
  20. "photos" => $resultPhotos,
  21. "followers" => $resultFollowers,
  22. "following" => $resultFollowing
  23. );
  24. $result[] = array_map("utf8_encode", $array);
  25. while($data = $searchPhotos->fetch(PDO::FETCH_ASSOC)){
  26. $array = array(
  27. "photo" => PATH.$data["photo"],
  28. "date_creation" => date('d/m/Y', strtotime($data["date_creation"]))
  29. );
  30. $result[] = array_map("utf8_encode", $array);
  31. }
  32. header('Content-type: application/json');
  33. echo json_encode($result);
  34. }
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement