Skip to content

Instantly share code, notes, and snippets.

@ZaeemSattar
Created November 25, 2016 17:12
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 ZaeemSattar/86e18d9725ffc6a7f83ae9d2f866be24 to your computer and use it in GitHub Desktop.
Save ZaeemSattar/86e18d9725ffc6a7f83ae9d2f866be24 to your computer and use it in GitHub Desktop.
<?php
$conn = new mysqli("localhost", "example", "password", "yourDB");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
echo 'error hai';
}
$sql ="SELECT * from Rooms";
$result = $conn->query($sql);
$rooms= array();
while($row = $result->fetch_assoc())
{
$obj= array();
array_push($obj,$row['rid']);
array_push($obj,$row['room_name']);
array_push($rooms,$obj);
}
echo json_encode($rooms);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment