Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $hostname = 'localhost';
- $username = 'root';
- $password = 'mypass';
- $database = 'mysql';
- $sql = "select * from general_log";
- //open connection to mysql db
- $connection = mysqli_connect($hostname,$username,$password,$database) or die("Error " . mysqli_error($connection));
- //fetch table rows from mysql db
- $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
- //create an array
- $emparray = array();
- while($row =mysqli_fetch_assoc($result))
- {
- $emparray[] = $row;
- }
- echo json_encode($emparray);
- //close the db connection
- mysqli_close($connection);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement