Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

206
Visualizações
Output text if the SQL value is empty

I'm trying to output the text 'N/A' into my table if there is an empty value stored for it in my SQL table. Here is what I have so far:

while($rowObj = $queryResult->fetch_object())
                {
                $eventTitle = $rowObj->eventTitle;
                $catDesc = $rowObj->catDesc;
                $catID = $rowObj->catID;
                $eventDescription = $rowObj->eventDescription;
                $venueName = $rowObj->venueName;
                $venueID = $rowObj->venueID;
                $eventStartDate = $rowObj->eventStartDate;
                $eventEndDate = $rowObj->eventEndDate;
                $eventPrice = $rowObj->eventPrice;                  

                echo "
                <tr>
                    <td> $eventTitle </td>
                    <td> " . (empty($catID)) ? 'N/A' : '$catDesc'. "</td>
                    <td> " . (empty($eventDescription)) ? 'N/A' : '$eventDescription'. "</td>
                    <td> " . (empty($venueID)) ? 'N/A' : '$venueName'. "</td>
                    <td> $eventStartDate </td> 
                    <td> $eventEndDate </td>
                    <td> $eventPrice </td>
                </tr>
                    ";
                }
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

if(empty($value)){
    echo "This value is empty";
}

Or if you want to insert a value "into the table" if a field is empty

if(empty($value)){
 $value = "N/A";
 //INSERT QUERY
}
over 4 years ago · Santiago Trujillo Relatório

0

Try this

$value = empty($value) ? "NA" : $value;

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda