Newer
Older
ournorth2021 / api / guardar_comentario.php
LuisOlaya on 8 Apr 2021 1 KB primer
<?php        
	include("../app/models/connect.php");

    $comentario = $_POST["comentario"];
    $id_user = $_POST["id_user"];
    $hoy = date("Y-m-d H:i:s");

    $query = mysqli_query($connect,"INSERT INTO Chat (id_asistente, comentario, padre, created_at ) 
    VALUES 
    (".$id_user.", '".$comentario."', 0, '".$hoy."' )");
	 
?>

<?php
$queryChat = mysqli_query($connect,"SELECT * FROM Chat ORDER BY created_at ASC ");
                while($dataChat = mysqli_fetch_array($queryChat)){
                    
                    $queryAsis = mysqli_query($connect,"SELECT * FROM Asistentes WHERE id = '".$dataChat["id_asistente"]."' ");
                    $dataAsis = mysqli_fetch_array($queryAsis);
                    
                    echo '
                    <div class="chat_box">
                        <div class="txt_envia">'.$dataAsis["nombre"].' '.$dataAsis["apellidos"].' - '.$dataChat["created_at"].'</div>
                        '.$dataChat["comentario"].'
                    </div>';
                }

?>

<script>
$( document ).ready(function() {
    $("#scroll_cont").animate({ scrollTop: $("#cont_chat").height() }, 500);
});
</script>