--- inc/pgBolesti-grupe.php 2001/09/03 15:52:15 1.1 +++ inc/pgBolesti-grupe.php 2001/09/28 23:34:37 1.2 @@ -1,3 +1,62 @@ prepare($sql); + if (!$sth) error("Cannot prepare query: \"$sql\""); + if (!$sth->execute()) error("Cannot execute query: \"$sql\""); + $grupa = $sth->fetchrow_array(); + $sth->finish(); + if ($grupa) $grupa = array_shift($grupa); + $tpl->assign("naslov", $grupa); + $grupe = array(); + $sql = "SELECT bolest_id, naziv FROM bolesti WHERE (grupa_bolesti_id = $id) AND (is_bolest)"; + $sth = $dbh->prepare($sql); + if (!$sth) error("Cannot prepare query: \"$sql\""); + if (!$sth->execute()) error("Cannot execute query: \"$sql\""); + while ($row = $sth->fetchrow_array()) { + array_push($grupe, array("id" => $row[0]."-0", "name" => MyEscape($row[1]))); + $sql = "SELECT alias_id, alias FROM bolesti_aliasi WHERE (bolest_id = ".$row[0].")"; + $sth2 = $dbh->prepare($sql); + if (!$sth2) error("Cannot prepare query: \"$sql\""); + if (!$sth2->execute()) error("Cannot execute query: \"$sql\""); + while ($row2 = $sth2->fetchrow_array()) + array_push($grupe, array("id" => $row[0]."-".$row2[0], "name" => MyEscape($row2[1]))); + $sth2->finish(); + } + $sth->finish(); + usort($grupe, "myComp"); + $slova = array(); + while (list($k, $v) = each($grupe)) { + $fl = $v["name"][0]; + for ($i = 0; $i < count($slova); $i++) if ($slova[$i]["fl"] == $fl) break; + if (!$slova[$i]) $slova[$i] = array("fl" => $fl, "grupe" => array()); + array_push($slova[$i]["grupe"], $v); + } + $tpl->assign("slova", $slova); + } else { + $tpl->assign("naslov", "Grupe bolesti"); + $grupe = array(); + $sql = "SELECT grupa_b_id, naziv FROM grupe_bolesti WHERE (grupa_b_id <> 0) AND (NOT plivamed)"; + $sth = $dbh->prepare($sql); + if (!$sth) error("Cannot prepare query: \"$sql\""); + if (!$sth->execute()) error("Cannot execute query: \"$sql\""); + while ($row = $sth->fetchrow_array()) + array_push($grupe, array("id" => $row[0], "name" => MyEscape($row[1]))); + $sth->finish(); + usort($grupe, "myComp"); + $slova = array(); + while (list($k, $v) = each($grupe)) { + $fl = $v["name"][0]; + for ($i = 0; $i < count($slova); $i++) if ($slova[$i]["fl"] == $fl) break; + if (!$slova[$i]) $slova[$i] = array("fl" => $fl, "grupe" => array()); + array_push($slova[$i]["grupe"], $v); + } + $tpl->assign("slova", $slova); + } + $tpl->assign("ID", $id); + $dbh->disconnect(); ?>