2 votes

Update a section through a query

I need to update a div every second, but this div has a query that has not worked correctly, since it is doing a query to mysql. I don't know if I have to add anything else, since it never loads anything from the BD

     include "../config/config.php";


    <div id="comen">

                            $come=mysqli_query($con, "select* from comentario where id_ticket='".$id_ticket."' order  by  fecha_comen desc");
                            foreach($come as $c):?>

                                 $users=mysqli_query($con, "select * from user where id='".$userb."'");
                                 foreach($users as $u); 
                                  <div class="<?php echo $usercss;?>">
                                   <div class="date">
                                        <?php echo $c['fecha_comen'];?>
                                           <div class="user">
                                              <i class="fa fa-user"></i>
                                               <span class="name">
                                                <?php echo $u['name'];?>
                                                <span class="type">
                                                 <?php echo $u['email'];?>
                                          <div class="message">
                                               <p> <?php echo $c['comentario'];?><br/>

    $(document).ready(function() {
        var refreshId =  setInterval( function(){
        $('#comen').load("comen.php");//actualiza el div
       }, 1000 );



The correct way to use the setInterval should be something like the following:

 function refrescar(){
        <TITLE>Título de la página</TITLE>
        <script src="https://code.jquery.com/jquery-1.11.3.js"></script>

        Aquí iría el contenido de la página
	var myVar = setInterval(refrescar,1000);


HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by: