Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. <?php
  2. header('Content-Type: application/json ');
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "root";
  6. $database = "base";
  7.  
  8. $conn = new mysqli($servername, $username, $password, $database);
  9. if ($conn->connect_error) {
  10. die("Ошибка соединения: " . $conn->connect_error);
  11. }
  12. $massiv = array();
  13. $id = isset($_GET['id']) ? $_GET['id'] : '';
  14.  
  15. $sql = "SELECT * FROM express where id between ($id+1) and ($id+20) ";
  16.  
  17. $stmt = $conn->prepare($sql); $stmt->execute();
  18.  
  19. $stmt->bind_result($id, $type, $added, $start, $finish, $kapper, $kf, $opisanie);
  20. while($stmt->fetch()){
  21.  
  22. $temp = [
  23. 'id'=>+$id,
  24. 'type'=>$type,
  25. 'added'=>$added,
  26. 'start'=>$start,
  27. 'finish'=>$finish,
  28. 'kapper'=>$kapper,
  29. 'kf'=>$kf,
  30. 'opisanie'=>$opisanie
  31. ];
  32.  
  33. array_push($massiv, $temp);
  34. }
  35. echo json_encode($massiv);
  36. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement