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

Annotation of /inc/pgKnjiznica-leksikon.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Fri Sep 28 23:34:37 2001 UTC (17 years, 11 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
Added some new pages to PLIVAmed. Some bugfixes.

1 ravilov 1.1 <?php
2 ravilov 1.3 include("inc/conn.php");
3 ravilov 1.2 include_once("inc/search.php");
4     $fields = array(
5     "pojam" => array("dbname" => "pojam", "caption" => "Pojam"),
6     "opis" => array("dbname" => "opis", "caption" => "Opis")
7     );
8 ravilov 1.3 if (!$id) {
9     list($srch, $qry_1, $qry_2) = Search($fields, array("pojam", "opis"), array(), "pojam");
10     # Win1250 -> ISO8859-2
11     if ($qry_1) $qry_1 = strtr($qry_1, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
12     if ($qry_2) $qry_2 = strtr($qry_2, "ŠÐÈƎšðèæž", "©ÐÈÆ®¹ðèæ¾");
13     $tpl->assign("index", $index);
14     $tpl->assign("srch", ($qry_1 || $qry_2) ? true : false);
15     $tpl->assign("SEARCH", $srch);
16     }
17 ravilov 1.2 $letters = Slova();
18     if (!$id && ($index || ($qry_1 || $qry_2))) {
19     $prvo_slovo = "UPPER(SUBSTRING(pojam FROM 1 FOR 1))";
20     $sql = "SELECT leks_id, $prvo_slovo AS prvo_slovo, pojam FROM leksikon";
21     $uvjet = array();
22     if ($index && $index != 1) {
23     if ($index == '@') for ($i = 0; $i < count($letters); $i++) array_push($uvjet, "($prvo_slovo <> '".$letters[$i]."')");
24     else array_push($uvjet, "($prvo_slovo = '".MyUpper($index)."')");
25     }
26     if ($qry_1) array_push($uvjet, "($qry_1)");
27     $uvjet = implode(" AND ", $uvjet);
28     if ($uvjet) $sql .= " WHERE $uvjet";
29     $sql .= " ORDER BY prvo_slovo, pojam";
30     $sth = $dbh->prepare($sql);
31     if (!$sth) error("Cannot prepare query: \"$sql\"");
32     if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
33     $slova = array();
34     $pojmovi = array();
35     unset($staro_slovo);
36     while ($row = $sth->fetchrow_array()) {
37     list($id2, $fl, $pojam) = $row;
38     if (!isset($staro_slovo)) $staro_slovo = $fl;
39     if (!($qry_1 || $qry_2) && $staro_slovo != $fl) {
40     array_push($slova, array("l" => $staro_slovo, "pojmovi" => $pojmovi));
41     $staro_slovo = $fl;
42     $pojmovi = array();
43     }
44     array_push($pojmovi, array("id" => $id2, "pojam" => MyEscape($pojam)));
45     }
46     $sth->finish();
47 ravilov 1.4 if (count($pojmovi) > 0) array_push($slova, array("l" => $staro_slovo, "pojmovi" => $pojmovi));
48 ravilov 1.2 $records = 0;
49 ravilov 1.3 for ($i = 0; $i < count($slova); $i++) $records += count($slova[$i]["pojmovi"]);
50 ravilov 1.2 $tpl->assign("records", $records);
51     $tpl->assign("slova", $slova);
52     $tpl->assign("stype", $stype);
53     }
54     if ($id) {
55     $sql = "SELECT pojam, opis FROM leksikon WHERE (leks_id = $id)";
56     $sth = $dbh->prepare($sql);
57     if (!$sth) error("Cannot prepare query: \"$sql\"");
58     if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
59     $row = $sth->fetchrow_array();
60     $sth->finish();
61     list($pojam, $opis) = $row;
62     $tpl->assign("pojam", MyEscape($pojam));
63     $tpl->assign("opis", MyEscape($opis));
64     }
65     $tpl->assign("letters", $letters);
66     $tpl->assign("ID", $id);
67     $dbh->disconnect();
68 ravilov 1.1 ?>

  ViewVC Help
Powered by ViewVC 1.1.26