I cannot see the elements of a table row

Asked

Viewed 36 times

0

I am trying to visualize elements of a row of a table of mine, only separately. And I have not been succeeding.

Follows the code:

<?php

require_once("conexao.php");

$id = $_POST['idlicita'];

$query = "select * from licitacao where idlicita = $id";

$resultado = mysqli_query($conexao,$query);
$visu = mysqli_fetch_assoc($resultado);

echo $visu["objeto"];

Excerpt from the form where the ID corresponding to the item I want to view:

<form action="visualiza.php" method="post">
  <input type="hidden" name="idlicita" value="<?$licitacao['idlicita']?>">
  <button type="submit" class="btn btn-success">Visualizar</button>
</form>

EDIT:

Mistake you’re making:

Warning: mysqli_fetch_assoc() expects Parameter 1 to be mysqli_result, Boolean Given in C: xampp htdocs painelnovo pages visualiza.php on line 10

  • To read a line you just don’t need the while, and only the instruction that is there :$visu = mysqli_fetch_assoc($resultado). In the database for this table licitacao has a field objeto ? And when you say "And I haven’t been succeeding" what happens? It makes a mistake ? If yes add the error to the question

  • I edited, took the while and put only one line

  • The $_POST doesn’t have the field idlicita. Confirm what you receive from the form with var_dump($_POST);

  • I don’t understand what you mean

  • 1

    <?$licitacao['idlicita']?> missing a = and should be <?=$licitacao['idlicita']?>

  • That really was it. Thank you very much

Show 1 more comment

1 answer

0

As @Isac said, problem is that you have an error in the code, you lack the = in <?$licitacao['idlicita']?>. Because of this, it is sending the variable empty and cannot fetch.

Browser other questions tagged

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