Problem when trying to display data in a table - php

Asked

Viewed 37 times

0

I’m having a problem trying to show nproposta, information on the application and dataregistada. Thanks in advance for any help. Thank you

<?php
    $ligaBD=mysqli_connect("localhost","root","","pap");

If(!$ligaBD) {
    printf("Ligação falhou: %\n",mysqli_connect_errno());
    exit();
}
?>

<section id="main">
  <div class="container">
    <div class="row">
      <div class="col-md-9">

          <!-- Latest Users -->

          <div class="panel panel-default">
            <div class="panel-heading">
              <h3 class="panel-title">titulo</h3>
            </div>

            <div class="panel-body">    
            <div class="row">
                  <div class="col-md-12">
                      <input class="form-control" type="text" placeholder="Pesquisar Nº de Proposta">
                  </div>
            </div>  

              <table class="table table-striped table-hover">
                  <tr>
                    <th>Nº da Proposta</th>
                    <th>Pedidos</th>
                    <th>Data</th>
                </tr>
            <?php
              $selectProp = "SELECT * FROM propostas,registo 
                            WHERE propostas.nproposta=registo.nproposta AND propostas.nproposta='$nproposta'";
              $resultado = mysqli_query($ligaBD, $selectProp);
              if (mysqli_num_rows($resultado) > 0) {
               // output data of each row
               while($row = mysqli_fetch_assoc($resultado)) {

            ?>
                <tr>
                    <td>
                    <?php
                    echo $row["nproposta"];
                    ?>
                    </td>

                      <td><p><a href=".\informaçãopedido.php?nproposta=<?php echo $row["nproposta"];?>">Pedido</a></p></td>

                    <td>
                    <?php
                    echo $row["dataregistada"];
                    ?>
                    </td>
                </tr>   
            <?php
                    }}
                mysqli_close($ligaBD);
            ?>                  
                </table>
                <a class="btn btn-default" href="./registardata.html">Registar Aquisição/Requisição</a>

            </div>
          </div>
      </div>
    </div>
  </div>
</section>

Erro:

  • you have some variable called $nproposta off that column?

  • The error is because you are calling a variable in your query that has not been defined.

1 answer

1


Your Query:

"SELECT * FROM propostas,registo 
 WHERE propostas.nproposta=registo.nproposta AND propostas.nproposta='$nproposta'";

'$nproposta' is not set or initialized, so the error

Browser other questions tagged

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