Selection does not display data on screen (php and mysql)

Asked

Viewed 19 times

0

<?php


class categoria {
    public function selecao($pesquisa){
        require_once 'conexao.php';
        $con = new conexao();
        $conn = $con->conectar();
        $sql = "select * from categoria where nome LIKE '%$pesquisa%'";
        $resultado= mysqli_query($conn, $sql);
        var_dump($resultado);
        $i=0;
//Creio que o erro está no código abaixo.
        while ($line = mysqli_fetch_array($resultado)){
            echo "$line[$i]";
            $i++;
        }
    }
    public function insercao(){

    }
    public function remover(){

    }
}
  • 1

    No need to quote the variable. Try echo $line[$i];.

  • the solution was simple: while ($line = mysqli_fetch_array($result)){ echo $line[0]; echo $line[1]; echo $line[2];

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.