Rescue BD Data Only Filled

Asked

Viewed 60 times

0

I’m having a problem when I have to show the database data and they’re empty because the name pops up and the blank space.

Nome: Pedro
Nome: Ricardo
Nome:
Nome:
Nome:

and wanted to know if it was possible to change this to show only the data Filled

   <p><b>Nome :</b> '.$exibe["Nome1"].' &nbsp;  &nbsp;  &nbsp; <b> Função :   </b>'.$exibe["Funcao1"].'</p>

        <p><b>Nome :</b> '.$exibe["Nome2"].' &nbsp;  &nbsp;  &nbsp; <b> Função : </b> '.$exibe["Funcao2"].'</p>

        <p><b>Nome :</b> '.$exibe["Nome3"].' &nbsp;  &nbsp;  &nbsp; <b> Função : </b> '.$exibe["Funcao3"].'</p>

        <p><b>Nome :</b> '.$exibe["Nome4"].' &nbsp;  &nbsp;  &nbsp; <b> Função : </b> '.$exibe["Funcao4"].'</p>

        <p><b>Nome :</b> '.$exibe["Nome5"].' &nbsp;  &nbsp;  &nbsp; <b> Função : </b> '.$exibe["Funcao5"].'</p>

        <p><b>Nome :</b> '.$exibe["Nome6"].' &nbsp;  &nbsp;  &nbsp; <b> Função : </b> '.$exibe["Funcao6"].'</p>

        <p><b>Nome :</b> '.$exibe["Nome7"].' &nbsp;  &nbsp;  &nbsp; <b> Função : </b> '.$exibe["Funcao7"].'</p>

        <p><b>Nome :</b> '.$exibe["Nome8"].' &nbsp;  &nbsp;  &nbsp; <b> Função : </b> '.$exibe["Funcao8"].'</p>
  • Could you put the code in trouble? Have you tried one trim() ?

  • I changed the question. There are several names that may not be filled in

  • I think it’s your poorly controlled loop. Put the code here so we can see the problem.

2 answers

2


That doesn’t work?

while($exibe = mysql_fetch_array($resultadoQuery) {
     if($exibe[nome] != NULL) {
          echo "<p><b>Nome: </b>$mostrar[nome] -- $mostrar[funcao]</p>
     }

EDIT:

You can’t do it (as posted in the comment):

<p>
      <?php if($exibe['nome6'] != NULL) {
            echo '<p><b>Nome: </b>'.$exibe['nome6'].'&nbsp;&nbsp; <b>Função: </b>'.$exibe['funcao6'];
           }
      ?>
</p>

<

  • I have a small problem putting this IF inside php. <p>' if($displays["Name6"] != NULL) { echo '<p><b>Name: </b>'. $displays["Name6"]. ' &nbsp;&nbsp; <b> Function : </b>'. $displays["Function6"]. }'</p>

  • I’ll edit the answer and show you how it does.

  • Look at the edited answer and see if that’s it, if it wasn’t, specify the error that happens.

  • I was having an error but it was because I was missing a ; before. and I didn’t use <?php

0

You can modify the query to

    SELECT * FROM tabela WHERE `nome` != NULL
  • Yes of course. But before the name appears, the text says "Name:"

  • The brhvitor6 tooltip can solve if your bank has this type of hole (empty fields). Otherwise, the problem may be in your loop. Is appearing "Name:" because it is not given from the database but html you are inserting in the hand.

  • But I don’t loop. I only show the BD data in order

  • And how are you rescuing the N records from the bank? Just posting the code to get an idea of what’s going on.

Browser other questions tagged

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