如果使用sql语句做的话 工作量太大了,于是尝试自己写一个交叉表的类,好二话不说,我们看看代码
<div class="codetitle"><a style="CURSOR: pointer" data="2903" class="copybut" id="copybut2903" onclick="doCopy('code2903')"> 代码如下:
如果使用sql语句做的话 工作量太大了,于是尝试自己写一个交叉表的类,好二话不说,我们看看代码
<div class="codetitle"><a style="CURSOR: pointer" data="2903" class="copybut" id="copybut2903" onclick="doCopy('code2903')"> 代码如下:
';
print_r ( $this->pivotValue );
}
/
渲染为table
/
function RenderToTable()
{
$resault = "\n";
$resault .= "<tr><td>$this->title</td>\n";
foreach ( $this->verticalColumn as $value )
{
$resault .= "<td>$value</td>\n";
}
$resault .= "</tr>\n";
foreach ( $this->horizontalColumn as $i )
{
$resault .= "<tr><td>$i</td>\n";
foreach ( $this->pivotValue [$i] as $value )
{
$resault .= "<td>$value</td>\n";
}
$resault .= "</tr>\n";
}
$resault .= "</table>";
return $resault;
}
/
构造交叉表
@param $data 数据源
@param $topPivot 头栏目字段
@param $leftPivot 左栏目字段
@param $measure 计算量
/
function __construct(array $data,$topPivot,$leftPivot,$measure)
{
$this->data = $data;
$this->leftPivot = $leftPivot;
$this->topPivot = $topPivot;
$this->measure = $measure;
$this->horizontalColumn = array ();
$this->verticalColumn = array ();
$this->InitPivot ();
$this->fillData ();
}
}
重点在于InitPivot方法及fillData方法。
InitPivot里面保证了所有的item都会有值(默认为0)
fillData方法使用选择填充添加的方法,将数据填充入我们装数据的$pivotValue里面。 然后喜欢怎么输出都可以了相关文章
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...