Created
July 10, 2017 13:11
-
-
Save thelazyindian/d4e6db7b09e8d2a9b47e3c40a83fec87 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 | |
//open connection to mysql db | |
$connection = mysqli_connect("localhost","root","","students") or die("Error " . mysqli_error($connection)); | |
//fetch table rows from mysql db | |
$sql = "select * from name"; | |
$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); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment