Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "root";
  5. $dbname = "pruebas";
  6. $conn = new mysqli($servername, $username, $password, $dbname);
  7.  
  8. $sql = "SELECT * FROM tabla1 WHERE id = $_SESSION["user_id"]";
  9. $result = $conn->query($sql);
  10. if ($result->num_rows > 0) {
  11. // output data of each row
  12. $data = array() ;
  13. while($row = $result->fetch_assoc()) {
  14. $data[] = $row;
  15.  
  16. }
  17. } else {
  18. echo "0 results";
  19. }
  20. echo json_encode($data);
  21. $conn->close();
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement