While is not loading the logs

Asked

Viewed 45 times

2

I am trying to repeat a region however, although mysqli_num_rows indicates that there are 9 records, while nothing is coming. My code is like this:

        $qry = "SELECT 
        pe_orclinhas.id_orclinha, 
        pe_orcgrupos.grupo_orcamento, 
        pe_orclinhas.dc, 
        pe_orclinhas.orclinha
        FROM pe_orcgrupos 
        INNER JOIN pe_orclinhas ON pe_orcgrupos.id_orca = pe_orclinhas.orcgrupo
        WHERE id_orclinha = $linhab";
        $consulta   = mysqli_query($MySQLi,$qry);
        $registros  = mysqli_num_rows($consulta);

        while($registro = mysqli_fetch_array($consulta)){

        $grp        = $registro[0];
        $tp         = $registro[1];
        $descr      = $registro[2];

    ?>
    <br />
    <em style='color: #003300;'><?php echo $grp; ?></em>
   <?php
   } 
   ?>   

2 answers

0

Try:

 <?php
    $qry = "SELECT 
    pe_orclinhas.id_orclinha, 
    pe_orcgrupos.grupo_orcamento, 
    pe_orclinhas.dc, 
    pe_orclinhas.orclinha
    FROM pe_orcgrupos 
    INNER JOIN pe_orclinhas ON pe_orcgrupos.id_orca = pe_orclinhas.orcgrupo
    WHERE id_orclinha = $linhab";
    $consulta   = mysqli_query($MySQLi,$qry);
    $registros  = mysqli_num_rows($consulta);

    while($registro = mysqli_fetch_array($consulta)){

      $grp        = $registro[0];
      $tp         = $registro[1];
      $descr      = $registro[2];

      echo "<br />"
      echo "<em style='color: #003300;'><" . $grp . "></em>"

    } ?>  

0


Instead of numbers, type the column name within the array index:

while($registro = mysqli_fetch_array($consulta)){

    $grp        = $registro['ColunaA'];
    $tp         = $registro['ColunaB'];
    $descr      = $registro['ColunaC'];

?>
<br />
<em style='color: #003300;'><?php echo $grp; ?></em>

Browser other questions tagged

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