Skip to content

Instantly share code, notes, and snippets.

@rudibroekhuizen
Last active January 26, 2017 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rudibroekhuizen/4c0d5005ab021a730d27f843d8fc5d83 to your computer and use it in GitHub Desktop.
Save rudibroekhuizen/4c0d5005ab021a730d27f843d8fc5d83 to your computer and use it in GitHub Desktop.
<?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