1 |
<?php |
<?php |
2 |
include_once("inc/conn.php"); |
include("inc/conn.php"); |
3 |
function mySS($a, $b) { |
function mySS($a, $b) { return MyCompare($a["name"], $b["name"]); } |
4 |
return MyCompare($a["name"], $b["name"]); |
function escape_quote($str) { return str_replace('"', """, $str); } |
|
} |
|
|
function escape_quote($str) { |
|
|
return str_replace('"', """, $str); |
|
|
} |
|
5 |
if (!$id) { |
if (!$id) { |
6 |
$simptomi = array(); |
$simptomi = array(); |
7 |
$sql = "SELECT simptom_id, naziv FROM simptomi WHERE (simptom_id <> 0)"; |
$sql = "SELECT simptom_id, naziv FROM simptomi WHERE (simptom_id <> 0) AND (overview != '')"; |
8 |
$sth = $dbh->prepare($sql); |
$sth = $dbh->prepare($sql); |
9 |
if (!$sth) error("Cannot prepare query: \"$sql\""); |
if (!$sth) error("Cannot prepare query: \"$sql\""); |
10 |
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
11 |
while ($row = $sth->fetchrow_array()) |
while ($row = $sth->fetchrow_array()) { |
12 |
array_push($simptomi, array("id" => $row[0]."-0", "name" => MyEscape($row[1]))); |
array_push($simptomi, array("id" => $row[0]."-0", "name" => MyEscape($row[1]))); |
13 |
$sth->finish(); |
$sql = "SELECT alias_id, alias FROM simptomi_aliasi WHERE (simptom_id = ".$row[0].")"; |
14 |
$sql = "SELECT simptom_id, alias_id, alias FROM simptomi_aliasi"; |
$sth2 = $dbh->prepare($sql); |
15 |
$sth = $dbh->prepare($sql); |
if (!$sth2) error("Cannot prepare query: \"$sql\""); |
16 |
if (!$sth) error("Cannot prepare query: \"$sql\""); |
if (!$sth2->execute()) error("Cannot execute query: \"$sql\""); |
17 |
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
while ($row2 = $sth2->fetchrow_array()) |
18 |
while ($row = $sth->fetchrow_array()) |
array_push($simptomi, array("id" => $row[0]."-".$row2[0], "name" => MyEscape($row2[1]))); |
19 |
array_push($simptomi, array("id" => $row[0]."-".$row[1], "name" => MyEscape($row[2]))); |
$sth2->finish(); |
20 |
|
} |
21 |
$sth->finish(); |
$sth->finish(); |
22 |
usort($simptomi, "mySS"); |
usort($simptomi, "mySS"); |
23 |
$slova = array(); |
$slova = array(); |
43 |
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
if (!$sth->execute()) error("Cannot execute query: \"$sql\""); |
44 |
$row = $sth->fetchrow_array(); |
$row = $sth->fetchrow_array(); |
45 |
$sth->finish(); |
$sth->finish(); |
46 |
list($naziv, $opis, $overview, $invest, $redflags) = $row; |
list($snaziv, $opis, $overview, $invest, $redflags) = $row; |
47 |
$tpl->assign("symptom", escape_quote($naziv)); |
$tpl->assign("symptom", escape_quote($snaziv)); |
48 |
$tpl->assign("opis", escape_quote($opis)); |
$tpl->assign("opis", escape_quote($opis)); |
49 |
$tpl->assign("overview", escape_quote($overview)); |
$tpl->assign("overview", escape_quote($overview)); |
50 |
#$tpl->assign("investigations", escape_quote($invest)); |
#$tpl->assign("investigations", escape_quote($invest)); |
80 |
$tpl->assign("povremeno", $povremeno); |
$tpl->assign("povremeno", $povremeno); |
81 |
$tpl->assign("rijetko", $rijetko); |
$tpl->assign("rijetko", $rijetko); |
82 |
$simptomi = array(); |
$simptomi = array(); |
83 |
|
$tmp = array(); |
84 |
|
for ($i = 0; $i < count($bolesti); $i++) $tmp[$i] = array("exists" => true, "val" => 1); |
85 |
|
array_push($simptomi, array("id" => "$sid-0", "name" => escape_quote($snaziv), "values" => $tmp)); |
86 |
for ($i = 0; $i < count($bolesti); $i++) { |
for ($i = 0; $i < count($bolesti); $i++) { |
87 |
if ($bolesti[$i]["vjerojatnost"] != 1) continue; |
if ($bolesti[$i]["vjerojatnost"] != 1) continue; |
88 |
$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"].")"; |
$sql = "SELECT simptomi.simptom_id, simptomi.naziv, simptomi.overview, 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"].")"; |
89 |
$sth2 = $dbh->prepare($sql); |
$sth2 = $dbh->prepare($sql); |
90 |
if (!$sth2) error("Cannot prepare query: \"$sql\""); |
if (!$sth2) error("Cannot prepare query: \"$sql\""); |
91 |
if (!$sth2->execute()) error("Cannot execute query: \"$sql\""); |
if (!$sth2->execute()) error("Cannot execute query: \"$sql\""); |
92 |
while ($row = $sth2->fetchrow_array()) { |
while ($row = $sth2->fetchrow_array()) { |
93 |
list($id, $simpt, $val) = $row; |
list($id, $simpt, $ov, $val) = $row; |
94 |
$simpt = escape_quote($simpt); |
$simpt = escape_quote($simpt); |
95 |
for ($j = 0; $j < count($simptomi); $j++) if ($simptomi[$j]["name"] == $simpt) break; |
for ($j = 0; $j < count($simptomi); $j++) if ($simptomi[$j]["name"] == $simpt) break; |
96 |
if (!$simptomi[$j]) { |
if (!$simptomi[$j]) { |
97 |
$tmp = array(); |
$tmp = array(); |
98 |
for ($k = 0; $k < count($bolesti); $k++) array_push($tmp, array("exists" => false)); |
for ($k = 0; $k < count($bolesti); $k++) array_push($tmp, array("exists" => false)); |
99 |
array_push($simptomi, array("id" => "$id-0", "name" => $simpt, "values" => $tmp)); |
array_push($simptomi, array("id" => $ov ? "$id-0" : "", "name" => $simpt, "values" => $tmp)); |
100 |
} |
} |
101 |
$simptomi[$j]["values"][$i]["exists"] = true; |
$simptomi[$j]["values"][$i]["exists"] = true; |
102 |
$simptomi[$j]["values"][$i]["val"] = $val; |
$simptomi[$j]["values"][$i]["val"] = $val; |