Skip to main content

Kartelak dituzten akatsak

<?php

$headers = array(
'Akatsa' => array('data' => 'Akatsa', 'field' => 'n.title', 'sort' => 'asc'),
'Arloa' => array('data' => 'Arloa', 'field' => 'td.name', 'sort' => 'asc'),
'Kartela',
);

$order = isset($_GET['order']) ? $headers[$_GET['order']]['field'] : 'n.title';
$sort = isset($_GET['sort']) ? $_GET['sort'] : 'asc';
$order_by = " ORDER BY $order $sort";

$result = db_query('SELECT n.nid, n.title akats, c.nid cnid, c.title fitxategi, td.name FROM node n LEFT JOIN node_relations nr ON n.nid = nr.pnid LEFT JOIN node c ON nr.nid = c.nid LEFT JOIN term_node tn ON n.nid = tn.nid AND tn.tid IN (SELECT tid FROM term_data WHERE vid = 11) LEFT JOIN term_data td ON tn.tid = td.tid WHERE n.type = "akats" AND nr.type = 508' . $order_by);

$rows = array();
while($row = db_fetch_object($result)){
$rows[] = array(
l($row->akats, "node/$row->nid"),
$row->name,
l($row->fitxategi, "node/$row->cnid"),
);
}

if($rows){
print theme('table', $headers, $rows);
} else {
print '<p>'.t('None').'</p>';
}

?>