0

Estou precisando replicar essa tabela do sistema ERP da empresa para o sistema WEB.

inserir a descrição da imagem aqui

Mas utilizando o código abaixo da imagem eu tenho o valor das variáveis que são 0 e 1.

inserir a descrição da imagem aqui

<table border="2">
          <tr>
              <th>  Id  </th>
              <th> Tipo </th>
              <th> Descrição </th>
              <th> NFe </th>
              <th> Bonificada </th>
              <th> Quebra </th>
              <th> Falha na Operação </th>
              <th> Transferência </th>
              <th> Movimenta Estoque </th>
              <th> Valida Preço </th>
              <th> Gera Entrada </th>
          </tr>
      <?php
            include ("conn.php");

              $result = "SELECT * FROM tipofat ORDER BY id";
              $resultado = mysqli_query($conn, $result);


              while ($row = mysqli_fetch_assoc($resultado)){

                  echo "<tr class='btn-default'>";
                      echo "<td class='get-func'>". $row['id'] ."</td>";
                      echo "<td class= 'get-cadfunc'>". $row['tp_faturamento'] ."</td>";
                      echo "<td class= 'get-cadfunc'>". $row['descricao'] ."</td>";
                      echo "<td class= 'get-cadfunc'>". $row['nfe'] ."</td>"; 
                      echo "<td class= 'get-cadfunc'>". $row['bnf_com_nota'] ."</td>";
                      echo "<td class= 'get-cadfunc'>". $row['bnf_sem_nota'] ."</td>";
                      echo "<td class= 'get-cadfunc'>". $row['falha_operacao'] ."</td>";
                      echo "<td class= 'get-cadfunc'>". $row['transferencia'] ."</td>";
                      echo "<td class= 'get-cadfunc'>". $row['mov_estoque'] ."</td>";
                      echo "<td class= 'get-cadfunc'>". $row['valida_preco'] ."</td>";
                      echo "<td class= 'get-cadfunc'>". $row['gera_entrada'] ."</td>";
                  echo "</tr>";
              }
          ?>
  </table>

Já tentei de milhares de formas fazer com que ao invés dos valores viessem checkox alterando minhas <td></td> , mas sem sucesso pois, os checkbox são inseridos nos lugares dos números mas não vem preenchidos/ checkados, vou deixar um exemplo abaixo das tentativas

echo '<td><input type="checkbox" name="nfe['.$row['nfe'].']" value="'. $row['nfe'] .' onclick="return false;" "</td>';
echo '<td><input type="checkbox" '. $row['nfe'] .' onclick="return false;" "</td>';
2
  • 2
    tenta colocar um if: echo "<td class= 'get-cadfunc'><input type='checkbox' name='nfe' value='nfe'" . if($row['nfe'] == 1) "checked" ."</td>"; 26/10/2017 às 17:33
  • tentei mas não funcionou
    – Victor
    26/10/2017 às 17:41

1 Resposta 1

1
<table border="2">
          <tr>
              <th>  Id  </th>
              <th> Tipo </th>
              <th> Descrição </th>
              <th> NFe </th>
              <th> Bonificada </th>
              <th> Quebra </th>
              <th> Falha na Operação </th>
              <th> Transferência </th>
              <th> Movimenta Estoque </th>
              <th> Valida Preço </th>
              <th> Gera Entrada </th>
          </tr>
      <?php
            include ("conn.php");

              $result = "SELECT * FROM tipofat ORDER BY id";
              $resultado = mysqli_query($conn, $result);


              while ($row = mysqli_fetch_assoc($resultado)){

                  echo "<tr class='btn-default'>";
                      echo "<td class='get-func'>". $row['id'] ."</td>";
                      echo "<td class= 'get-cadfunc'>". $row['tp_faturamento'] ."</td>";
                      echo "<td class= 'get-cadfunc'>". $row['descricao'] ."</td>";
                      echo "<td class= 'get-cadfunc'><input type=\"checkbox\"". (($row['nfe'] == 1) ? " checked" : "")." disabled></td>"; 
                      echo "<td class= 'get-cadfunc'><input type=\"checkbox\"". (($row['bnf_com_nota'] == 1) ? " checked" : "")." disabled></td>";
                      echo "<td class= 'get-cadfunc'><input type=\"checkbox\"". (($row['bnf_sem_nota'] == 1) ? " checked" : "")." disabled></td>";
                      echo "<td class= 'get-cadfunc'><input type=\"checkbox\"". (($row['falha_operacao'] == 1) ? " checked" : "")." disabled></td>";
                      echo "<td class= 'get-cadfunc'><input type=\"checkbox\"". (($row['transferencia'] == 1) ? " checked" : "")." disabled></td>";
                      echo "<td class= 'get-cadfunc'><input type=\"checkbox\"". (($row['mov_estoque'] == 1) ? " checked" : "")." disabled></td>";
                      echo "<td class= 'get-cadfunc'><input type=\"checkbox\"". (($row['valida_preco'] == 1) ? " checked" : "")." disabled></td>";
                      echo "<td class= 'get-cadfunc'><input type=\"checkbox\"". (($row['gera_entrada'] == 1) ? " checked" : "")." disabled></td>";
                  echo "</tr>";
              }
          ?>
  </table>
3
  • obrigado justamente o que eu queria, mas tem como eu fazer eles ficarem desabilitados também ? tentei com disabled e não tive sucesso
    – Victor
    26/10/2017 às 17:47
  • Alterei a resposta, é com disabled mesmo, verifique se você havia colocado da maneira correta. 26/10/2017 às 17:52
  • Obrigado, eu digitei errado mesmo, coloquei disabeld rsrs mas ficou justo como você informou, mais uma vez obrigado por compartilhar sua sabedoria
    – Victor
    26/10/2017 às 17:56

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .