Skip to content

Instantly share code, notes, and snippets.

@ZaeemSattar
Created November 25, 2016 17:10
Show Gist options
  • Save ZaeemSattar/298be9c7b07848c32cc0cf990a8b4e83 to your computer and use it in GitHub Desktop.
Save ZaeemSattar/298be9c7b07848c32cc0cf990a8b4e83 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);
}
$rid=$_POST["room_id"];
$sql ="SELECT * from Messages where rid='$rid'";
$result = $conn->query($sql);
$rooms= array();
while($row = $result->fetch_assoc())
{
$obj= array();
array_push($obj,$row['uid']);
array_push($obj,$row['rid']);
array_push($obj,$row['message']);
array_push($obj,$row['username']);
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