valdeir2000

StackOverflow 274494

Feb 5th, 2018
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2.  
  3. class Video {
  4. public $videoName = "";
  5. public $videoViews = "";
  6.  
  7. public function __construct($videoName, $videoViews) {
  8. $this->videoName = $videoName;
  9. $this->videoViews = $videoViews;
  10. }
  11. }
  12.  
  13. $conectar = mysqli_connect("localhost", "***", "***", "***") or die("Erro 001 - Conection lost");
  14.  
  15. if ($conectar->connect_errno) {
  16. echo "Falha ao conectar com o mysql: (" . $conectar->connect_errno . ") " . $conectar->connect_error;
  17. }
  18.  
  19. $start = isset($_GET['start']) ? $_GET['start'] : 0;
  20. $data = array();
  21. $query = "SELECT * FROM videos ORDER BY id DESC LIMIT {$start}, 5";
  22. $resultado = mysqli_query($conectar, $query);
  23. while($linhas = mysqli_fetch_assoc($resultado)){
  24. $data[] = array(
  25. "videoName" => $linhas['nome'],
  26. "videoViews" => $linhas['tempo']
  27. );
  28. }
  29.  
  30. echo json_encode($data);
Advertisement
Add Comment
Please, Sign In to add comment