1 |
ravilov |
1.1 |
<?php |
2 |
|
|
function my_cmp2($a, $b) { return MyCompare($a["title"], $b["title"]); } |
3 |
ravilov |
1.2 |
include("inc/conn.php"); |
4 |
|
|
$sql = "SELECT MAX(level) FROM specijalizacije"; |
5 |
ravilov |
1.1 |
$sth = $dbh->prepare($sql); |
6 |
|
|
if (!$sth) error("Cannot prepare query: \"$sql\""); |
7 |
|
|
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
8 |
ravilov |
1.2 |
$levels = array_shift($sth->fetchrow_array()); |
9 |
|
|
$sth->finish(); |
10 |
|
|
if (!$levels) $levels = 1; |
11 |
ravilov |
1.1 |
$menu3 = array(); |
12 |
ravilov |
1.2 |
for ($i = 0; $i < $levels; $i++) { |
13 |
|
|
$sql = "SELECT spec_id, opis, level FROM specijalizacije WHERE (spec_id != 0) AND (NOT link) AND (level = ".($i + 1).")"; |
14 |
|
|
$sth = $dbh->prepare($sql); |
15 |
|
|
if (!$sth) error("Cannot prepare query: \"$sql\""); |
16 |
|
|
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
17 |
|
|
$tmp = array(); |
18 |
|
|
while ($row = $sth->fetchrow_array()) { |
19 |
|
|
list($id2, $txt) = $row; |
20 |
|
|
array_push($tmp, array("id" => $id2, "title" => MyEscape($txt))); |
21 |
|
|
} |
22 |
|
|
$sth->finish(); |
23 |
|
|
usort($tmp, "my_cmp2"); |
24 |
|
|
array_push($menu3, $tmp); |
25 |
ravilov |
1.1 |
} |
26 |
ravilov |
1.3 |
$MENU3_section = ($section == "home" || $section == "arhiva" || $section == "linkovi" || $section == "kalendar") ? $section : "home"; |
27 |
|
|
$tpl->assign("MENU3_section", $MENU3_section); |
28 |
ravilov |
1.1 |
$tpl->assign("MENU3", $menu3); |
29 |
|
|
?> |