So if I have been trying to create an If statement in my HTML PHP file where it should display as “N/A” if the 'Workshop_Contact'=="0".
I’ve tried some ways but seems like I couldn’t find the solution
Here is the line code:
<h4 class="card-title text-danger">Contact:
<?=
if ($row['Workshop_Contact']==0){
echo "N/A";
}
else{
echo "0" . $row['Workshop_Contact'];
}
?>
</h4>
Advertisement
Answer
Could use a ternary
<h4 class="card-title text-danger"> Contact: <?= $row['Workshop_Contact'] == 0 ? 'N/A' : '0' . $row['Workshop_Contact'] ?> </h4>