内容发布的分年度统计代码
<?php
function custom_count_pull (){
$sql = "SELECT type, COUNT(nid) AS number, FROM_UNIXTIME(created, '%Y') AS createdate FROM {node} GROUP BY type, createdate ORDER BY createdate DESC" ;
$result = db_query ( $sql );
$article_count = array();
while ( $data = db_fetch_object ( $result )){
if (isset( $article_count [ $data -> type ])) {
$article_count [ $data -> type ][ $data -> createdate ] = $data -> number ;
} else {
$article_count [ $data -> type ] = array( $data -> createdate => $data -> number );
}
}
$today = date ( "Y" );
$years = array( $today - 2 , $today - 1 , $today );
$output .= "
| Type | {$years[0]} | {$years[1]} | {$years[2]} |
|---|---|---|---|
| $real_type_name | {$value[$year]} | 0 |
" ;
return $output ;
}
print custom_count_pull ();
?>
