Loop in Json [PHP and MYSQL]

0

I have a data visualization page from a table bd, and one of the cells of this table in html is actually a loop. I want to do the inline editing, which I've used in other projects ( link ), but with all the fixed fields. This time, I do not have all tds fixed, for example, if an agency has 10 protocols, 10 tds will be generated, if it has 1 it will be generated 1 in the visualization.

Could someone give me a light on how to get these ids?

Part of the table view where the loop has

                 echo'<td>'.$turno.'</td>';
                 echo'<td>'.$funcionarios.'</td>';
                 echo'<td>'.$qt_col.'</td>';
                 echo'<td>'.$tipo_ocorrencia.'</td>';

   //Busca as qtds de tipos de atividades cadastradas da agência para previstro e realizado
    $dados3 = $pdo->prepare("SELECT * FROM protocolos_agencias where id_prot=:id_prot  and tipo_ocorrencia=:tipo and status=1 ");

      $dados3->bindParam(':id_prot',$id_prot, PDO::PARAM_INT);
      $dados3->bindParam(':tipo',$tipo_ocorrencia, PDO::PARAM_STR);

    $dados3->execute();

         while($table3 = $dados3->fetch(PDO::FETCH_OBJ)){

          echo'<td>'.$table3->qtd_atividades.'</td>';
                                    }


                              echo'<td>'.$tempo.'</td>';

Jquery edit script

<script>


$(document).ready(function(){  
     $('#example5').Tabledit({
      url:'atividade/action.php',
      columns:{
       identifier:[0, 'id_registro'],
       editable:[[2, 'atividade'], [3, 'turno'],[4, 'funcionarios'],[5, 'qtd'],[6, 'tipo'],[7, 'qtd_atividade'],[8,'tempo']]
      },

      restoreButton:false,
       buttons:{
          confirm: {
            class: 'btn btn-sm btn-danger',
            html: 'Desativar?'
        },
         delete:{
            class: 'btn btn-sm btn-danger',
            html: '<span class="glyphicon glyphicon-trash"></span> &nbsp',
            action: 'delete'
        },

         edit:{
            class: 'btn btn-sm btn-success',
            html: '<span class="glyphicon glyphicon-edit"></span> &nbsp',
            action: 'edit'
        },

       },
      onSuccess:function(data, textStatus, jqXHR)
      {
       if(data.action == 'delete')
       {
        $('#'+data.id).remove();
       }
      }
     });

});  


    </script>

The error is here: [7, 'qtd_atividade'],[8,'tempo']] because if I have an agency with more than 1 type of activity, it will not work.

    
asked by anonymous 09.03.2018 / 19:20

0 answers