Jump to content

[SOLVED] if database field empty display N/A


bigbenbuilders

Recommended Posts

I need that if the database field is empty it displays a message.  Here is what I have tried but I know that the fields have information and is displaying N/A.  My if statement must be wrong or if any one knows a better way to do it would be great.  Thanks in advance!

 


<?php
// Connect database.
$host=""; // Host name.
$db_user=""; // MySQL username.
$db_password=""; // MySQL password.
$database=""; // Database name.
mysql_connect($host,$db_user,$db_password);
mysql_select_db($database);

$result=mysql_query("SELECT * FROM financial WHERE financial.Scholarship_group='Art' AND financial.Type='Scholarship'");

?>



<?php

while($row=mysql_fetch_assoc($result)){
?>


        <strong>Name: <?php echo $row['Name']; ?></strong><br>
      
   <strong>Selection Criterion:</strong> <?php if (mysql_num_rows($row) == 0) {
echo "N/A";
}
else {
echo $row['Selection_Criterion'];
}
?>

<br>
  <strong>Award Information:</strong> <?php if (mysql_num_rows($row) == 0) {
echo "N/A";
}
else {
echo $row['Award_Information'];
}
?>

<?php } // End while loop. ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.