Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. <?php
  2. $hostname = 'localhost';
  3. $username = 'root';
  4. $password = 'mypass';
  5. $database = 'mysql';
  6. $sql = "select * from general_log";
  7.  
  8. //open connection to mysql db
  9. $connection = mysqli_connect($hostname,$username,$password,$database) or die("Error " . mysqli_error($connection));
  10.  
  11. //fetch table rows from mysql db
  12. $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
  13.  
  14. //create an array
  15. $emparray = array();
  16. while($row =mysqli_fetch_assoc($result))
  17. {
  18. $emparray[] = $row;
  19. }
  20. echo json_encode($emparray);
  21.  
  22. //close the db connection
  23. mysqli_close($connection);
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement