--- inc/menuMED.php 2001/09/19 12:23:57 1.1 +++ inc/menuMED.php 2001/09/25 15:38:04 1.2 @@ -1,17 +1,27 @@ prepare($sql); if (!$sth) error("Cannot prepare query: \"$sql\""); if (!$sth->execute()) error("Cannot execute query: \"$sql\""); + $levels = array_shift($sth->fetchrow_array()); + $sth->finish(); + if (!$levels) $levels = 1; $menu3 = array(); - while ($row = $sth->fetchrow_array()) { - list($id2, $txt) = $row; - array_push($menu3, array("id" => $id2, "title" => MyEscape($txt))); + for ($i = 0; $i < $levels; $i++) { + $sql = "SELECT spec_id, opis, level FROM specijalizacije WHERE (spec_id != 0) AND (NOT link) AND (level = ".($i + 1).")"; + $sth = $dbh->prepare($sql); + if (!$sth) error("Cannot prepare query: \"$sql\""); + if (!$sth->execute()) error("Cannot execute query: \"$sql\""); + $tmp = array(); + while ($row = $sth->fetchrow_array()) { + list($id2, $txt) = $row; + array_push($tmp, array("id" => $id2, "title" => MyEscape($txt))); + } + $sth->finish(); + usort($tmp, "my_cmp2"); + array_push($menu3, $tmp); } - $sth->finish(); - usort($menu3, "my_cmp2"); $tpl->assign("MENU3", $menu3); - $menu = array(); ?>