欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

views 视图 计算 计算次数 某一列的和 有大用 有大大用

<?php

/**
* Implementation of hook_menu().
*/

//function shipingzhongcustomfour_perm(){
//  return array('view total field baoming xuefei');
//}

function shipingzhongcustomfour_get_view_rowcount(){

 $view = views_get_current_view();

 $page_total = count($view->result);

 //return "<div class='views_count'><strong>嗯条目数 <font color='red'>" . $page_total . "</font></strong></div>";

 if(isset($view->total_rows)){
   return "<div class='views_count'><strong>条目数 <font color='red'>" . $view->total_rows . "</font></strong></div>";
 } else {
   return "<div class='views_count'><strong>条目数 <font color='red'>" . $page_total . "</font></strong></div>";
 }
}

function  shipingzhongcustomfour_get_total_field_baomingxuefei_value(){
 $view = views_get_current_view();
 $sql = $view->build_info['query'];
 $args = $view->build_info['query_args'];
 $result = db_query($sql,$args);
 $total_field_baomingxuefei_value = 0;
 while ($obj = db_fetch_object($result)) {
   $total_field_baomingxuefei_value += floatval($obj->node_data_field_xueshenname_field_baomingxuefei_value);
 }
 return "<div class='views_count'><strong>总计报名学费 <font color='red' id='total_field_baomingxuefei_value'>" . $total_field_baomingxuefei_value . "</font> 元</strong></div>";
}

function  shipingzhongcustomfour_get_xiaonenfenxi_count(){
 $view = views_get_current_view();
 $sql = $view->build_info['query'];
 $args = $view->build_info['query_args'];
 $result = db_query($sql,$args);
 $jiqi_count=0;
 while ($obj = db_fetch_object($result)) {
   if(!empty($obj->node_data_field_xnfx_jiqi_field_xnfx_jiqi_value)){
     $jiqi_count++;
   }
 }
 return "<div class='views_count'><strong>使用机器的次数 <font color='red'>" . $jiqi_count . "</font> </strong></div>";
}


普通分类: