5465ab75c85b8809ebcc45e98ecb37645c296efb
[www.energie.vellum.cz.git] / clanek.php
1 <?php $cvs_id='$Id$';
2
3         include("common.php");
4
5         prepvar("year" ,"[0-9]+");
6         prepvar("month","[0-9]+");
7         prepvar("id"   ,"[0-9]+",false/*required*/);
8
9         $title_tail=title_name($year,$month);
10         $result=db_query("select name,contents from $tb_clanek where year=$year and month=$month"
11                         .(isset($id) ? " and id=$id" : "")." order by id");
12         if (isset($id) && 1==mysql_num_rows($result)) {
13                 $row=mysql_fetch_array($result);
14                 $title_tail.=" - ".$row["name"];
15                 }
16
17         heading();
18         print("<h1>".title_name($year,$month)."</h1>\n");
19
20         if (isset($id) && 1!=mysql_num_rows($result))
21                 fatal("Zadaný èlánek nebyl nalezen");
22
23 function print_article($row)
24 {
25         print("<h2>".htmlspecialchars($row["name"])."</h2>\n".$row["contents"]);
26 }
27
28         if (isset($id))
29                 print_article($row);
30         else
31                 while (($row=mysql_fetch_array($result)))
32                         print_article($row);
33         mysql_free_result($result);
34
35         footer();
36 ?>