Commit | Line | Data |
---|---|---|
bc13d5d6 H |
1 | <? |
2 | require "../header_db.php"; | |
3 | ||
4 | Header ("Pragma: no-cache"); | |
5 | Header ("Cache-Control: no-cache"); | |
6 | Header ("Expires: ".GMDate("D, d M Y H:i:s")." GMT"); | |
7 | ||
8 | if ($insert=="yes") { | |
9 | echo "<form action=$PHP_SELF>"; | |
10 | echo "Otazka: <input type=text name=question>"; | |
11 | echo "id rubriky: <input type=text name=id_rubrika>"; | |
12 | echo "<br>Aktivni: ano:<input type=radio name=active value=yes>ne:<input type=radio name=active value=no><br>"; | |
13 | echo "Odpoved 1 <input type=text name=option1><br>"; | |
14 | echo "Odpoved 2 <input type=text name=option2><br>"; | |
15 | echo "Odpoved 3 <input type=text name=option3><br>"; | |
16 | echo "Odpoved 4 <input type=text name=option4><br>"; | |
17 | echo "Odpoved 5<input type=text name=option5><br>"; | |
18 | echo "<input type=submit name=insert value=Pridej>"; | |
19 | } | |
20 | ||
21 | elseif (IsSet($info)) { | |
22 | $sqlcmd = "Select * from polls where id_poll='$info'"; | |
23 | $result =mysql_query($sqlcmd); | |
24 | $riadok=mysql_fetch_array($result); | |
25 | echo "<center><h3>Anketa: $riadok[question]</h3>"; | |
26 | echo "odpovedalo $riadok[responses] lidi"; | |
27 | $sqlcmd = "Select * from poll_options where id_poll='$info'"; | |
28 | $result =mysql_query($sqlcmd); | |
29 | echo "<table>"; | |
30 | while ($riadok=mysql_fetch_array($result)) { | |
31 | echo "<tr><Td>$riadok[text]</td><td>$riadok[number] lidi </td></tr>"; | |
32 | } | |
33 | echo "</centeR>"; | |
34 | } | |
35 | ||
36 | ||
37 | elseif ($insert=="Pridej") { | |
38 | $sqlcmd = "insert into polls set responses=0,question='$question', active='$active',id_rubrika='$id_rubrika'"; | |
39 | $result =mysql_query($sqlcmd); | |
40 | $id_poll=mysql_insert_id(); | |
41 | if (IsSet($option1)) { | |
42 | $sqlcmd = "insert into poll_options set text='$option1', id_poll='$id_poll' ,number='0'"; | |
43 | mysql_query($sqlcmd); | |
44 | } | |
45 | if (IsSet($option2) AND $option2!="") { | |
46 | $sqlcmd = "insert into poll_options set text='$option2', id_poll='$id_poll' ,number='0'"; | |
47 | mysql_query($sqlcmd); | |
48 | } | |
49 | ||
50 | if (IsSet($option3) AND $option3!="") { | |
51 | $sqlcmd = "insert into poll_options set text='$option3', id_poll='$id_poll' ,number='0'"; | |
52 | mysql_query($sqlcmd); | |
53 | } | |
54 | ||
55 | if (IsSet($option4) AND $option4!="") { | |
56 | $sqlcmd = "insert into poll_options set text='$option4', id_poll='$id_poll' ,number='0'"; | |
57 | mysql_query($sqlcmd); | |
58 | } | |
59 | ||
60 | if (IsSet($option5) AND $option5!="") { | |
61 | $sqlcmd = "insert into poll_options set text='$option5', id_poll='$id_poll' ,number='0'"; | |
62 | mysql_query($sqlcmd); | |
63 | } | |
64 | } | |
65 | ||
66 | ||
67 | else { | |
68 | if ($up=="Uloz" AND IsSet($update)) { | |
69 | ||
70 | ||
71 | $sqlcmd="update polls set active='$$update' where id_poll='$update'"; | |
72 | mysql_query($sqlcmd); | |
73 | } | |
74 | $sqlcmd = "Select active,id_poll,question from polls order by time desc"; | |
75 | $result= mysql_query($sqlcmd); | |
76 | echo "<table><tr><th>ID</th><th>Otazka</th><th>Aktivni?</th></tr>"; | |
77 | while ($record = mysql_fetch_array($result)) { | |
78 | echo "<form action=$PHP_SELF method=post>"; | |
79 | echo "<td>",$record["id_poll"],"</td>"; | |
80 | echo "<td><a href=/~hromi/activa/admin2/polladmin.php?info=",$record["id_poll"],">",$record["question"],"</td>"; | |
81 | echo "<td>Ano:<input type=radio name=active$record[id_poll] value=yes"; | |
82 | if ($record["active"]=="yes") echo " checked"; | |
83 | echo ">"; | |
84 | echo " Ne:<input type=radio name=active$record[id_poll] value=no"; | |
85 | if ($record["active"]=="no") echo " checked"; | |
86 | echo "><input name=up type=submit value=Uloz><input type=hidden name=update value=$record[id_poll]</form></td></tr>"; | |
87 | } | |
88 | echo "</table>"; | |
89 | echo "<br><a href=$PHP_SELF?insert=yes>Pridat novu anketu.</a>"; | |
90 | } | |
91 | ?> |