欢迎转载,转载请注明出处。
首页 >> Drupal >> druapl显示每个用户的文章数

druapl显示每个用户的文章数

来源:     作者:    发布日期:2008-07-17     浏览次数:
  1. <?php 
  2. $how_many_per_page = 100; 
  3.  
  4. $query = "SELECT {node}.created AS Date, name, type, COUNT(*) AS Total 
  5. FROM {node} JOIN {users} 
  6. ON {node}.uid = {users}.uid 
  7. GROUP BY FROM_DAYS(TO_DAYS(FROM_UNIXTIME({node}.created))), name, type"; 
  8.  
  9. $count = "SELECT COUNT(*) FROM (SELECT DISTINCT FROM_DAYS(TO_DAYS(FROM_UNIXTIME({node}.created))) AS DATE,  uid, type FROM {node}) AS Data_row"
  10.  
  11. $results = pager_query($query$how_many_per_page, 0, $count); 
  12.  
  13. $header = array(t('Date'), t('Name'), t('Type'), t('Total')); 
  14.  
  15. $attributes = array('width' => '75%'
  16.                                'align' => 'center'
  17.                                'border' => '2'
  18.                             ); 
  19.  
  20. $rows = array(); 
  21.  
  22. while ($quote = db_fetch_array($results)) { 
  23.       $rows[] = array(date('Y/m/d',$quote['Date']),  $quote['name'], $quote['type'], $quote['Total']); 
  24.       } 
  25.  
  26. if (count($rows)) { 
  27.       echo theme('table'$header$rows$attributes); 
  28.       echo theme('pager', NULL, $how_many_per_page); 
  29.       } 
  30.       else { echo 'No results found'; } 
  31. ?> 

使用版本:Drupal 5.X

关键词:
  • 上一篇:Drupal theme - Hammerhead
  • 下一篇: