/[health_html]/inc/pgBolesti-grupe.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /inc/pgBolesti-grupe.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by ravilov, Mon Sep 3 15:52:15 2001 UTC revision 1.2 by ravilov, Fri Sep 28 23:34:37 2001 UTC
# Line 1  Line 1 
1  <?php  <?php
2          // ...          include("inc/conn.php");
3            function myComp($a, $b) { return MyCompare($a["name"], $b["name"]); }
4            function escape_quote($str) { return str_replace('"', "&quot;", $str); }
5            if ($id) {
6                    $grupe = array();
7                    $sql = "SELECT naziv FROM grupe_bolesti WHERE (grupa_b_id = $id)";
8                    $sth = $dbh->prepare($sql);
9                    if (!$sth) error("Cannot prepare query: \"$sql\"");
10                    if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
11                    $grupa = $sth->fetchrow_array();
12                    $sth->finish();
13                    if ($grupa) $grupa = array_shift($grupa);
14                    $tpl->assign("naslov", $grupa);
15                    $grupe = array();
16                    $sql = "SELECT bolest_id, naziv FROM bolesti WHERE (grupa_bolesti_id = $id) AND (is_bolest)";
17                    $sth = $dbh->prepare($sql);
18                    if (!$sth) error("Cannot prepare query: \"$sql\"");
19                    if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
20                    while ($row = $sth->fetchrow_array()) {
21                            array_push($grupe, array("id" => $row[0]."-0", "name" => MyEscape($row[1])));
22                            $sql = "SELECT alias_id, alias FROM bolesti_aliasi WHERE (bolest_id = ".$row[0].")";
23                            $sth2 = $dbh->prepare($sql);
24                            if (!$sth2) error("Cannot prepare query: \"$sql\"");
25                            if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");
26                            while ($row2 = $sth2->fetchrow_array())
27                                    array_push($grupe, array("id" => $row[0]."-".$row2[0], "name" => MyEscape($row2[1])));
28                            $sth2->finish();
29                    }
30                    $sth->finish();
31                    usort($grupe, "myComp");
32                    $slova = array();
33                    while (list($k, $v) = each($grupe)) {
34                            $fl = $v["name"][0];
35                            for ($i = 0; $i < count($slova); $i++) if ($slova[$i]["fl"] == $fl) break;
36                            if (!$slova[$i]) $slova[$i] = array("fl" => $fl, "grupe" => array());
37                            array_push($slova[$i]["grupe"], $v);
38                    }
39                    $tpl->assign("slova", $slova);
40            } else {
41                    $tpl->assign("naslov", "Grupe bolesti");
42                    $grupe = array();
43                    $sql = "SELECT grupa_b_id, naziv FROM grupe_bolesti WHERE (grupa_b_id <> 0) AND (NOT plivamed)";
44                    $sth = $dbh->prepare($sql);
45                    if (!$sth) error("Cannot prepare query: \"$sql\"");
46                    if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
47                    while ($row = $sth->fetchrow_array())
48                            array_push($grupe, array("id" => $row[0], "name" => MyEscape($row[1])));
49                    $sth->finish();
50                    usort($grupe, "myComp");
51                    $slova = array();
52                    while (list($k, $v) = each($grupe)) {
53                            $fl = $v["name"][0];
54                            for ($i = 0; $i < count($slova); $i++) if ($slova[$i]["fl"] == $fl) break;
55                            if (!$slova[$i]) $slova[$i] = array("fl" => $fl, "grupe" => array());
56                            array_push($slova[$i]["grupe"], $v);
57                    }
58                    $tpl->assign("slova", $slova);
59            }
60            $tpl->assign("ID", $id);
61            $dbh->disconnect();
62  ?>  ?>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.26