title: cakephp pass a variable to the view
body: <p>I want to add a column that is the sum of the val_max column in the database</p>
  
  <p>function controller</p>
  
  <pre><code>function admin_affiche() {
        $this-&gt;Part-&gt;recursive = 1;
        $parts = $this-&gt;Part-&gt;find('all', array(
  
         ));
        $totalvals = $this-&gt;Part-&gt;Market-&gt;find('first', array(
                 array('fields' =&gt; array('sum(Market.val_max) AS valtotal'))));
  
        $this-&gt;set('valtotal', $totalvals);
        $this-&gt;set('parts', $parts);
  
     }
  </code></pre>
  
  <p>view</p>
  
  <pre><code>&lt;td class="tg-031e"&gt;&lt;?php $totalvals[0]['valtotal'] ?&gt;&lt;/td&gt;
  </code></pre>
  
  <p>the error is <strong>Undefined variable: totalvals</strong></p>
  
  <p>pass variavle to view</p>