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

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

revision 1.1 by ravilov, Fri Sep 28 23:34:37 2001 UTC revision 1.3 by ravilov, Sat Oct 27 16:54:50 2001 UTC
# Line 1  Line 1 
1  <?php  <?php
2          $sql = "SELECT url, naslov, opis FROM linkovi ORDER BY naslov";          function myCmp($a, $b) { return MyCompare($a["naslov"], $b["naslov"]); }
3          $sth = $dbh->prepare($sql);          function myCmp2($a, $b) { return MyCompare($a["naziv"], $b["naziv"]); }
4          if (!$sth) error("Cannot prepare query: \"$sql\"");          $naslov = "";
5          if (!$sth->execute()) error("Cannot execute query: \"$sql\"");          if ($spec) $grupa = $spec;
6          $linkovi = array();          if ($grupa) {
7          while ($row = $sth->fetchrow_array())                  $sql = "SELECT opis FROM specijalizacije WHERE (link) AND (spec_id = $grupa)";
8                  array_push($linkovi, array("url" => MyEscape($row[0]), "naslov" => MyEscape($row[1]), "opis" => MyEscape($row[2])));                  $sth = $dbh->prepare($sql);
9          $sth->finish();                  if (!$sth) error("Cannot prepare query: \"$sql\"");
10          $tpl->assign("linkovi", $linkovi);                  if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
11                    $row = $sth->fetchrow_array();
12                    $sth->finish();
13                    if ($row) $row = array_shift($row);
14                    if ($row) $naslov = $row;
15                    $sql = "SELECT url, naslov, opis FROM linkovi".($spec?", link_spec":"")." WHERE (linkovi.link_id = link_spec.link_id) AND (link_spec.spec_id = $grupa)".($spec?" AND (link_spec.spec_id = $spec)":"");
16                    $sth = $dbh->prepare($sql);
17                    if (!$sth) error("Cannot prepare query: \"$sql\"");
18                    if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
19                    $linkovi = array();
20                    while ($row = $sth->fetchrow_array())
21                            array_push($linkovi, array("url" => MyEscape($row[0]), "naslov" => MyEscape($row[1]), "opis" => MyEscape($row[2])));
22                    $sth->finish();
23                    usort($linkovi, "myCmp");
24                    $tpl->assign("linkovi", $linkovi);
25            } else {
26                    $sql = "SELECT spec_id, opis FROM specijalizacije WHERE (link)";
27                    $sth = $dbh->prepare($sql);
28                    if (!$sth) error("Cannot prepare query: \"$sql\"");
29                    if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
30                    $grupe = array();
31                    while ($row = $sth->fetchrow_array())
32                            array_push($grupe, array("id" => $row[0], "naziv" => MyEscape($row[1])));
33                    $sth->finish();
34                    usort($grupe, "myCmp2");
35                    $tpl->assign("grupe", $grupe);
36            }
37            if ($spec) {
38                    $sql = "SELECT opis FROM specijalizacije WHERE spec_id = $spec";
39                    $sth = $dbh->prepare($sql);
40                    if (!$sth) error("Cannot prepare query: \"$sql\"");
41                    if (!$sth->execute()) error("Cannot execute query: \"$sql\"");
42                    $row = $sth->fetchrow_array();
43                    $sth->finish();
44                    if ($row) $row = array_shift($row);
45                    if ($row) {
46                            if ($naslov) $naslov .= " - ";
47                            $naslov .= $row;
48                    }
49            }
50            $tpl->assign("grupa", $grupa);
51            $tpl->assign("naslov", $naslov);
52            $dbh->disconnect();
53  ?>  ?>

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

  ViewVC Help
Powered by ViewVC 1.1.26