0) AND (node.type in ('gallery')) GROUP BY doctor_nid, menu_ref; "); $str = array(); $str2 = array(); while ($item = db_fetch_object($result)) { if ( !empty($item->doctor_nid ) ) { $dnid = $item->doctor_nid; $mnid = $item->menu_ref; if ( $n = node_load($dnid) ) { $str[$dnid] = l($n->title, "gallery/all/".$dnid); if ( $n2 = node_load($mnid) ) { $ref = $n2->field_menu_ref[0]['nid']; if ( $ref && $n3 = node_load( $ref ) ) { $weight = $n3->node_weight; $str2[$dnid][$weight] = l($n3->title, "gallery/$ref/$dnid"); } } } } }; foreach ( $str as $k => $v ) { print "
"; print "

$v

"; $t = $str2[$k]; ksort($t); print theme('item_list', $t); print "
"; } ?>