Код выводит таблицу с колонками:
<?php
$header = array ('Тип', 'Кол-во', 'Последний','Название');
$rows = array();
$q = "SELECT n.type as tipo,count(n.type) as cant,max(DATE_FORMAT(FROM_UNIXTIME(n.changed), '%Y-%m-%%d')) as lastpost FROM {node} n group by n.type";
$result = db_query ($q);
while ( $row = db_fetch_object ( $result ) )
{
$q = "SELECT max(n.nid) as max FROM {node} n where n.type='$row->tipo'";
$result2 = db_query ($q);
$r = db_fetch_object ( $result2 );
$q = "SELECT n.nid as nid,n.title as title FROM {node} n where n.nid=$r->max";
$result2 = db_query ($q);
$r = db_fetch_object ( $result2 );
$link = l($r->title, "node/".$r->nid);
$rows[] = array ( 'data' => array ( t($row->tipo), $row->cant,$row->lastpost, $link )) ;
}
if (!$rows) {
$rows[] = array(array('data' => t('Данных нет.'), 'colspan' => 2));
}
print theme('table', $header, $rows);
?>
Comments
Post new comment