Community Documentation

Report with count of the posts made by each user

Last updated February 22, 2008. Created by cwgordon7 on November 15, 2007.
Edited by add1sun, bestknight. Log in to edit this page.

Copy the following in the body of a page and set the input filter to PHP.

<?php
$how_many_per_page
= 100;

$query = "SELECT {node}.created AS Date, name, type, COUNT(*) AS Total
FROM {node} JOIN {users}
ON {node}.uid = {users}.uid
GROUP BY FROM_DAYS(TO_DAYS(FROM_UNIXTIME({node}.created))), name, type"
;

$count = "SELECT COUNT(*) FROM (SELECT DISTINCT FROM_DAYS(TO_DAYS(FROM_UNIXTIME({node}.created))) AS DATE,  uid, type FROM {node}) AS Data_row";

$results = pager_query($query, $how_many_per_page, 0, $count);

$header = array(t('Date'), t('Name'), t('Type'), t('Total'));

$attributes = array('width' => '75%',
                              
'align' => 'center',
                              
'border' => '2',
                            );

$rows = array();

while (
$quote = db_fetch_array($results)) {
     
$rows[] = array(date('Y/m/d',$quote['Date']),  $quote['name'], $quote['type'], $quote['Total']);
      }

if (
count($rows)) {
      echo
theme('table', $header, $rows, $attributes);
      echo
theme('pager', NULL, $how_many_per_page);
      }
      else { echo
'No results found'; }
?>

About this page

Drupal version
Drupal 5.x

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here