select returning blank and have already entered things in the database (php with msql)

Asked

Viewed 26 times

-1

inserir a descrição da imagem aqui

someone can help me don’t know why is not appearing the result on the page

  • Please [Edit] exchange the image for code, easy so we can help. You can even leave the screenshot of the result, but the text code is important. And also describe what is the result that should have appeared.

  • Where is the connection to the bank? And I also did not see the function to execute the query you did.

  • The name of your field in the bank is campo1?

1 answer

1

You need to connect to the database and run the query.

To connect would be something like:

function conectar()
{
    try
    {
        //Localhost
        $host = "localhost";
        $user = "root";
        $password = "";
        $database = "nomedobanco";

        $conn = mysqli_connect($host, $user, $password, $database);            
    } catch (Exception $ex) {
        die("Erro de conexão: " . mysqli_connect_error());
    }

    return $conn;
}

And to perform something like:

function listar()
{
    $link = conectar();

    $query = "SELECT * FROM tablea";

    $result = mysqli_query($link, $query) or die(mysqli_error($link));

    return $result;
}

Browser other questions tagged

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