<?php 
include "ChatConfig.php";
$query_chat = $connection->prepare(
                            "SELECT * FROM group_$_POST[group] WHERE id=:id"
                        );
                        $query_chat->bindParam(
                            "id",
                            $_POST["id"],
                            PDO::PARAM_STR
                        );
                        $query_chat->execute();
                        $result_chat = $query_chat->fetch(PDO::FETCH_ASSOC);
                        
                        $query_chat_user = $connection->prepare(
                            "SELECT * FROM users WHERE username=:username"
                        );
                        $query_chat_user->bindParam(
                            "username",
                            $result_chat["username"],
                            PDO::PARAM_STR
                        );
                        $query_chat_user->execute();
                        $result_chat_user = $query_chat_user->fetch(PDO::FETCH_ASSOC);
                        if($result_chat["replay"] == null){
                            $rep = '0';
                        } else {
                            $rep = $result_chat["replay"];
                        }
                        if($result_chat["type"] == null){
                            $typ = '0';
                        } else {
                            $typ = $result_chat["type"];
                            $pth = $result_chat["path"];
                        }
                        $json = array('username'=>$result_chat["username"], 'message'=>$result_chat["message"],'link'=>$pth, 'replay'=>$rep, 'time'=>$result_chat["time"], 'type'=>$typ, 'name'=>$result_chat_user['name'], 'profile'=>$result_chat_user['profile'], 'tick'=>$result_chat_user["tick"]);
print_r( json_encode($json));