title: mysql if num rows more than 0 show results else echo no recent activity - not working?
body: <p>I am trying to get this code to work. I am getting a list of results from my database which are less than 30 days old. And displaying them in my div.</p>
  
  <p>This works fine, however if there are no results I want to echo out No Recent Activity, and I am unable to get this bit to work. I am using a MySQL num row count and else statement to try and get it to do what I need but It won't show no recent activity even if there is no results.</p>
  
  <p>Please can someone show me where I am going wrong.</p>
  
  <p>thanks,</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;div class="dashboard_stats"&gt;
  &lt;?php require_once 'config.php'; ?&gt;
  
  &lt;?php
  $table = 'recent_activity';
  
  
  echo '&lt;div class="dashboard_stats_heading"&gt;&lt;table class="table_other"&gt;&lt;tr&gt;&lt;td&gt;Description&lt;/td&gt;&lt;td&gt;Reference&lt;/u&gt;&lt;/td&gt;&lt;td&gt;Status&lt;/td&gt;&lt;td&gt;Supplier Name&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;';
  
  $query1 = "SELECT * FROM $table WHERE user_id = '{$_SESSION['id']}' AND date &gt; NOW() - INTERVAL 30 DAY ORDER BY date DESC";
  $result1 = mysql_query($query1);
  while ($row1 = mysql_fetch_array($result1)) {
  
  
      if(mysql_num_rows($result1)&gt;0){
  
      $date = $row1['date'];
      require_once 'time_ago.php';
  
      if($row1['activity_type']==='Bank'){
          $activity_type = 'Bank Details Changed';
      }else{
          if($row1['activity_type']==='Username'){
              $activity_type = 'Username Changed';   
          } else {
              if($row1['activity_type']==='Password'){
                  $activity_type = 'Password Changed';   
              } else {
                  if($row1['activity_type']==='Contact'){
                      $activity_type = 'Contact Details Changed';   
                  } else {
                      if($row1['activity_type']==='Invoice'){
                          $activity_type = 'Invoice Submitted';   
                      } else {
                          if($row1['activity_type']==='Trading'){
                              $activity_type = 'Trading Suspended';     
                          }
                      }
                  }
              }
          }
      }
  
  
  
  
          echo '&lt;table&gt;&lt;tr&gt;&lt;td&gt;&lt;p&gt;'.$activity_type.'&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;1234&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;'.$row1['status'].'&lt;/p&gt;&lt;/td&gt;&lt;td&gt;&lt;p&gt;'; 
          echo pretty_relative_time($row1['date']);
          echo '&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class="separator"&gt;&lt;/tr&gt;&lt;/table&gt;';
  
      }else{
  
          echo   '&lt;div id="content"&gt;No Recent Activity&lt;/div&gt;';   
  
      }
  }
  
  echo '&lt;/div&gt;';
  ?&gt;
  
  &lt;/div&gt;
  </code></pre>