DataTables warning

DataTables warning

RiardoRiardo Posts: 2Questions: 1Answers: 0
edited May 2023 in Free community support

Olá!:

estou com esse erro sou novato, aprendendo ainda. como corrigir?

DataTables warning: table id=listar-usuario - Requested unknown parameter '5' for row 0, column 5. For more information about this error, please see http://datatables.net/tn/4

segue código:

<?php
// Incluir a conexao com o banco de dados
include_once 'conexao.php';
$dados_requisicao = $_REQUEST;

// Obter a quantidade de registros no banco de dados
   $query_qnt_usuarios = "SELECT COUNT(id) AS qnt_usuarios FROM cliente";
   $result_qnt_usuarios = $conn->prepare($query_qnt_usuarios);
   $result_qnt_usuarios->execute();
   $row_qnt_usuarios = $result_qnt_usuarios->fetch(PDO::FETCH_ASSOC);

$query_usuarios = "SELECT * FROM cliente ORDER BY id DESC LIMIT :inicio, :quantidade";
$result_usuarios = $conn->prepare($query_usuarios);
$result_usuarios->bindParam(':inicio', $dados_requisicao['start'], PDO::PARAM_INT);
$result_usuarios->bindParam(':quantidade', $dados_requisicao['length'], PDO::PARAM_INT);
$result_usuarios->execute();

while($row_usuario = $result_usuarios->fetch(PDO::FETCH_ASSOC)){
    
    //var_dump($row_usuario);
    extract($row_usuario);
    $registro =[];
    $registro[] = $id;
    $registro[] = $nome;
    $registro[] = $email;
    $registro[] = $telefone;
    $registro[] = $cpfcnpj;
    $dados[] = $registro;

} 

Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

Answers

  • kthorngrenkthorngren Posts: 20,783Questions: 26Answers: 4,858

    The place to start is with the troubleshooting steps at the ink in the error:
    http://datatables.net/tn/4

    Looks like you are returning 5 columns but guessing you have at least 6 columns defined in the table. They need to match.

    Kevin

  • RiardoRiardo Posts: 2Questions: 1Answers: 0

    na minha tabela tenho estes dados:
    $registro[] = $id;
    $registro[] = $nome;
    $registro[] = $email;
    $registro[] = $telefone;
    $registro[] = $cpfcnpj;

    no meu HTML esta desta maneira:

    (são os botões de "Editar"; "Apagar"
    Id Nome email telefone cpfcnpj Ações
  • allanallan Posts: 62,454Questions: 1Answers: 10,254 Site admin

    Please link to a test case showing the issue, per the forum rules.

    Allan

  • kthorngrenkthorngren Posts: 20,783Questions: 26Answers: 4,858

    How are you populating the Ações column? Please show your Datatables initialization code.

    Kevin

Sign In or Register to comment.