Last active
January 26, 2017 20:32
-
-
Save rudibroekhuizen/4c0d5005ab021a730d27f843d8fc5d83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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, JSON_NUMERIC_CHECK); | |
//close the db connection | |
mysqli_close($connection); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment