title: checking if table has entries with cakephp
body: <p>I'm using cakephp and trying to check if a table has data entered in it. If there is no data, display a message saying "no data". If there is data, display it.</p>
  
  <p>I can display the results fine, I'm just not sure how to tell cakephp to check if there is any info in the table. </p>
  
  <p>Do I put the logic for checking in my model and in the view reference that model function? I'm new to cakephp and MVC in general, so I'm still trying to get a  hang of the way data flows.</p>
  
  <p>Edit- Here is my code for the index file. When I just hae $mysorts listed without a function I received the following error. </p>
  
  <p>Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in...</p>
  
  <pre><code>&lt;h1&gt;Sorted Entries&lt;/h1&gt;
  &lt;?php
   echo $this-&gt;Html-&gt;link("Add List", array('action' =&gt; 'add')); 
     if (!empty($mysorts)) {
    ?&gt;
  &lt;table&gt;
     &lt;tr&gt;
         &lt;th&gt;ID&lt;/th&gt;
         &lt;th&gt;Original&lt;/th&gt;
         &lt;th&gt;Sorted&lt;/th&gt;
     &lt;/tr&gt;
  
    &lt;?php  foreach ($mysorts as $mysort): ?&gt;
           &lt;tr&gt;
               &lt;td&gt;&lt;?php echo $mysort['Mysort']['id']; ?&gt;&lt;/td&gt;
               &lt;td&gt;
                   &lt;?php echo $mysort['Mysort']['original']; ?&gt;
               &lt;/td&gt;
               &lt;td&gt; &lt;?php echo $mysort['Mysort']['sorted']; ?&gt;
               &lt;/td&gt;
           &lt;/tr&gt;
     &lt;?php endforeach;
           } else {
          echo '&lt;p&gt;No results found!&lt;/p&gt;';
          }
     ?&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>And here is my controller
      
  
  <pre><code>class MysortsController extends AppController {
    public $helpers = array('Html', 'Form');
  
    public function index() {
           $this -&gt;set('mysorts', $this-&gt;Mysort-&gt;find('all'));  
  
    }
  
   public function add() {
          if($this-&gt;request-&gt;is('post')) {
          $this-&gt;Session-&gt;setFlash('yes');
          $this-&gt;redirect(array('action' =&gt; 'index'));
          }
   }
  
   function isempty(){
             $mysorts = $this-&gt;Mysort-&gt;find('all');
             $this-&gt;set('mysorts', $mysorts);
    }
  }
  ?&gt;
  </code></pre>