Guest User

Untitled

a guest
Jan 24th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. <?php
  2. //Conexão e consulta ao Mysql
  3. $con = mysqli_connect('localhost', 'root', '');
  4. mysqli_select_db($con, 'sis_tam');
  5. $qry = mysqli_query($con, "select * from clientes");
  6.  
  7. //Pegando os nomes dos campos
  8. $num_fields = mysqli_num_fields($qry);//Obtém o número de campos do resultado
  9.  
  10. for($i = 0;$i<$num_fields; $i++){//Pega o nome dos campos
  11. $fields[] = mysqli_fetch_field_direct($qry, $i);
  12. }
  13.  
  14. //Montando o cabeçalho da tabela
  15. $table = '<table class="table table-hover table-inverse" style="margin-top:50;background-color: #37444a; color:lightgrey;"> <tr>';
  16.  
  17. for($i = 0;$i < $num_fields; $i++){
  18. $table .= '<th>'.$fields[$i].'</th>'; //ESSA É A LINHA DO ERRO
  19. }
  20.  
  21. //Montando o corpo da tabela
  22. $table .= '<tbody style="
  23. background-color: #86979e;
  24. color: #37444a;
  25. ">';
  26. while($r = mysqli_fetch_array($qry)){
  27. $table .= '<tr>';
  28. for($i = 0;$i < $num_fields; $i++){
  29. $table .= '<td>'.$r[$fields[$i]].'</td>';
  30. }
  31.  
  32. // Adicionando botão de exclusão
  33. $table .= '<td><form action="banco/deleteC.php" method="post">'; //formulário com método post que vai para deleteF.php
  34. $table .= '<input type="hidden" name="ID" value="'.$r['ID'].'">';
  35. $table .= '<button class="btn btn-danger">Excluir</button>'; //aqui está o seu botão
  36. $table .= '</form></td>';
  37. }
  38.  
  39. //Finalizando a tabela
  40. $table .= '</tbody></table>';
  41.  
  42. //Imprimindo a tabela
  43. echo $table;
  44.  
  45. ?>
  46.  
  47. $table .= '<th>'.$fields[$i].'</th>';
Add Comment
Please, Sign In to add comment