将数组值从控制器传递到cakephp中的视图

时间:2015-08-27 07:05:34

标签: php

//控制器

social account type

//查看

public function viewcategorys1() {
$this->loadModel("Category");
$total = $this->Category->find('all', array('fields' =>array('sum(Category.rate)   AS ctotal'), 'conditions'=>array('Category.parentid' => 0)));
$this->set('sum',$total);
print_r($total);
}

在控制器中我写了'print_r',因此它显示为put:

<?php 
foreach($sum as $ctotal):
echo $ctotal['Category']['rate'];
endforeach;
?> 

根据视图文件中编写的代码,它显示输出为:

Array ( [0] => Array ( [0] => Array ( [ctotal] => 16250 ) ) )

如何在view.ctp文件中打印值16225?     请帮帮我

0 个答案:

没有答案