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. ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.