Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
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 answers
Answer question

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 Report

0

Try this

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

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!