<p>
<br />
<?php
$headers = array(
'Akatsa' => array('data' => 'Akatsa', 'field' => 'pn.title', 'sort' => 'asc'),
'Arloa' => array('data' => 'Arloa', 'field' => 'td.name', 'sort' => 'asc'),
'Ariketa' => array('data' => 'Ariketa', 'field' => 'n.title', 'sort' => 'asc'),
'',
);
$order = isset($_GET['order']) ? $headers[$_GET['order']]['field'] : 'pn.title';
$sort = isset($_GET['sort']) ? $_GET['sort'] : 'asc';
$order_by = " ORDER BY $order $sort";
$result = db_query('SELECT n.nid, n.title, a.moodle, nr.pnid, nr.type, pn.title akats, td.name FROM node n
LEFT JOIN ariketa a ON n.nid = a.nid
LEFT JOIN node_relations nr ON n.nid = nr.nid AND nr.type = "509"
LEFT JOIN node pn ON nr.pnid = pn.nid
LEFT JOIN term_node tn ON pn.nid = tn.nid
LEFT JOIN term_data td ON tn.tid = td.tid
WHERE a.moodle != "" AND (td.vid = 11 OR ISNULL(td.vid))'.$order_by);
while($row = db_fetch_object($result)){
$title = l($row->title, "node/$row->nid");
$ariketa = '<a href="javascript:;" onClick="window.open(\'http://www.bergarakoeuskara.eus/moodle/mod/hotpot/view.php?id='.$row->m…;\', \'leiho\', \'width=800,height=600\')">Ikusi</a>';
$akatsa = l($row->akats, "node/$row->pnid");
$arloa = $row->name;
$rows[] = array($akatsa, $arloa, $title, $ariketa);
}
print theme('table', $headers, $rows);
?></p>