if($_POST['message'] != ""){
$id_client = $_SESSION['id_client'];
$text = $_POST['message'];
$type = "2";
$data = date("Y-m-d H:i:s");
$status = "0";
$query = "INSERT INTO messages (id_dialog, text, type, data, status) SELECT
id_dialog, $text, $type, $data, $status
FROM dialogs WHERE id_client = '$id_client'";
$result = db_connection($query);
exit;
}
echo $query;