<?php
$results = db_query("SELECT name,tid FROM term_data WHERE vid = 32 AND tid NOT IN (SELECT t.tid FROM term_node t,node n WHERE n.nid = t.nid AND n.type = 'image') AND tid NOT IN (SELECT parent FROM term_hierarchy) ORDER BY tid ASC;");
$headers = array('TID', 'Name');
$rows = array();
while($row = db_fetch_array($results)){
$rows[] = array(l($row['tid'], 'taxonomy/term/'.$row['tid']), $row['name']);
}
echo theme('table',$headers, $rows);
?>