/[health_html]/inc/pgSimptomi.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

Contents of /inc/pgSimptomi.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Mon Sep 3 15:52:16 2001 UTC (22 years, 7 months ago) by ravilov
Branch: MAIN
Made the menu on the left into images. More bugfixes.

1 <?php
2 include_once("inc/conn.php");
3 function mySS($a, $b) {
4 return MyCompare($a["name"], $b["name"]);
5 }
6 function escape_quote($str) {
7 return str_replace('"', "&quot;", $str);
8 }
9 if (!$id) {
10 $simptomi = array();
11 $sql = "SELECT simptom_id, naziv FROM simptomi WHERE (simptom_id <> 0)";
12 $sth = $dbh->prepare($sql);
13 if (!$sth) error("Cannot prepare query: \"$sql\"");
14 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
15 while ($row = $sth->fetchrow_array())
16 array_push($simptomi, array("id" => $row[0]."-0", "name" => MyEscape($row[1])));
17 $sth->finish();
18 $sql = "SELECT simptom_id, alias_id, alias FROM simptomi_aliasi";
19 $sth = $dbh->prepare($sql);
20 if (!$sth) error("Cannot prepare query: \"$sql\"");
21 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
22 while ($row = $sth->fetchrow_array())
23 array_push($simptomi, array("id" => $row[0]."-".$row[1], "name" => MyEscape($row[2])));
24 $sth->finish();
25 usort($simptomi, "mySS");
26 $slova = array();
27 while (list($k, $v) = each($simptomi)) {
28 $fl = $v["name"][0];
29 for ($i = 0; $i < count($slova); $i++) if ($slova[$i]["fl"] == $fl) break;
30 if (!$slova[$i]) $slova[$i] = array("fl" => $fl, "simptomi" => array());
31 array_push($slova[$i]["simptomi"], $v);
32 }
33 $tpl->assign("slova", $slova);
34 } else {
35 list($sid, $aid) = explode("-", $id);
36 $sql = "SELECT ".($aid?"simptomi_aliasi.alias":"simptomi.naziv")." FROM simptomi".($aid?", simptomi_aliasi":"")." WHERE (simptomi.simptom_id = $sid)".($aid?" AND (simptomi_aliasi.simptom_id = simptomi.simptom_id) AND (simptomi_aliasi.alias_id = $aid)":"");
37 $sth = $dbh->prepare($sql);
38 if (!$sth) error("Cannot prepare query: \"$sql\"");
39 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
40 $row = $sth->fetchrow_array();
41 $sth->finish();
42 array_push($PATH, MyUpper($row[0]));
43 $sql = "SELECT naziv, opis, overview, investigations, red_flags FROM simptomi WHERE (simptomi.simptom_id = $sid)";
44 $sth = $dbh->prepare($sql);
45 if (!$sth) error("Cannot prepare query: \"$sql\"");
46 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
47 $row = $sth->fetchrow_array();
48 $sth->finish();
49 list($naziv, $opis, $overview, $invest, $redflags) = $row;
50 $tpl->assign("symptom", escape_quote($naziv));
51 $tpl->assign("overview", escape_quote($overview));
52 $tpl->assign("investigations", escape_quote($invest));
53 $tpl->assign("red_flags", escape_quote($redflags));
54 $sql = "SELECT alias FROM simptomi_aliasi WHERE (simptom_id = $sid) ORDER BY alias";
55 $sth = $dbh->prepare($sql);
56 if (!$sth) error("Cannot prepare query: \"$sql\"");
57 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
58 $aliasi = array();
59 while ($row = $sth->fetchrow_array()) array_push($aliasi, MyEscape($row[0]));
60 $sth->finish();
61 $tpl->assign("aliases", $aliasi);
62 $sql = "SELECT bolesti.bolest_id, bolesti.naziv, simptomi_bolesti.vjerojatnost FROM bolesti, simptomi_bolesti WHERE (bolesti.bolest_id = simptomi_bolesti.bolest_id) AND (simptomi_bolesti.simptom_id = $sid) ORDER BY simptomi_bolesti.vjerojatnost, bolesti.naziv";
63 $sth = $dbh->prepare($sql);
64 if (!$sth) error("Cannot prepare query: \"$sql\"");
65 if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
66 $bolesti = array();
67 $uobicajeno = $povremeno = $rijetko = false;
68 while ($row = $sth->fetchrow_array()) {
69 list($bid, $naziv, $vjer) = $row;
70 if ($vjer == 1) $uobicajeno = true;
71 if ($vjer == 2) $povremeno = true;
72 if ($vjer == 3) $rijetko = true;
73 array_push($bolesti, array(
74 "id" => "$bid-0",
75 "naziv" => escape_quote($naziv),
76 "vjerojatnost" => $vjer
77 ));
78 }
79 $sth->finish();
80 $tpl->assign("bolesti", $bolesti);
81 $tpl->assign("uobicajeno", $uobicajeno);
82 $tpl->assign("povremeno", $povremeno);
83 $tpl->assign("rijetko", $rijetko);
84 $simptomi = array();
85 for ($i = 0; $i < count($bolesti); $i++) {
86 if ($bolesti[$i]["vjerojatnost"] != 1) continue;
87 $sql = "SELECT simptomi.simptom_id, simptomi.naziv, sorter.value FROM simptomi, sorter WHERE (sorter.simptom_main_id = $sid) AND (sorter.simptom_id = simptomi.simptom_id) AND (sorter.bolest_id = ".$bolesti[$i]["id"].")";
88 $sth2 = $dbh->prepare($sql);
89 if (!$sth2) error("Cannot prepare query: \"$sql\"");
90 if (!$sth2->execute()) error("Cannot execute query: \"$sql\"");
91 while ($row = $sth2->fetchrow_array()) {
92 list($id, $simpt, $val) = $row;
93 $simpt = escape_quote($simpt);
94 for ($j = 0; $j < count($simptomi); $j++) if ($simptomi[$j]["name"] == $simpt) break;
95 if (!$simptomi[$j]) {
96 $tmp = array();
97 for ($k = 0; $k < count($bolesti); $k++) array_push($tmp, array("exists" => false));
98 array_push($simptomi, array("id" => "$id-0", "name" => $simpt, "values" => $tmp));
99 }
100 $simptomi[$j]["values"][$i]["exists"] = true;
101 $simptomi[$j]["values"][$i]["val"] = $val;
102 }
103 $sth2->finish();
104 }
105 $tpl->assign("simptomi", $simptomi);
106 }
107 $dbh->disconnect();
108 $tpl->assign("ID", $id);
109 ?>

  ViewVC Help
Powered by ViewVC 1.1.26