vendredi 26 février 2016

php echo if query is empty

I'm querying a database but when the result is empty i want to output a table row displaying "nothing to display" but the if seems to always return true.

Here's my code...

$priorityincidentsQ         = mysql_query("SELECT * FROM applications WHERE pi >= ('2') ");
while($priorityincidentsR   = mysql_fetch_object($priorityincidentsQ)) 
  {
    if (empty($priorityincidentsR)) {
      echo "<tr><td class=\"closedcallscell centered\"><b>Nothing to display</b></td></tr>";    
    } else {        
      echo "<tr><td class=\"closedcallscell\"><b>$priorityincidentsR->application_friendly_name</b></td>";
      echo "<td  class=\"closedcallscell table_row_small\"><center>$priorityincidentsR->pi</center></td></tr>"; 
    }
  }

Aucun commentaire:

Enregistrer un commentaire