| 1 | <?php include("../header_db.php"); ?> |
| 2 | |
| 3 | <?php |
| 4 | if (IsSet($poll) AND IsSet($option)) { |
| 5 | $sqlcmd="update polls set responses=responses+1 where id_poll=$poll"; |
| 6 | $result=mysql_query($sqlcmd); |
| 7 | $sqlcmd="update poll_options set number=number+1 where id_option=$option"; |
| 8 | $result=mysql_query($sqlcmd); |
| 9 | } |
| 10 | |
| 11 | else { |
| 12 | echo "<table><tr><td colspan=3 align=center>"; |
| 13 | $sqlcmd="select * from polls where active='yes' order by id_poll desc limit 1"; |
| 14 | $result=mysql_query($sqlcmd); |
| 15 | $riadok=mysql_fetch_array($result); |
| 16 | echo $riadok[question]; |
| 17 | $percent=$riadok[responses]/100; |
| 18 | if (!$percent) $percent=1; |
| 19 | echo "</td></tr>"; |
| 20 | $sqlcmd="select * from poll_options where id_poll='$riadok[id_poll]'"; |
| 21 | |
| 22 | $result=mysql_query($sqlcmd); |
| 23 | while ($riadok2=mysql_fetch_array($result)) { |
| 24 | (int) $count = (int) ($riadok2[number]/$percent); |
| 25 | echo "<tr><td><a href=$PHP_SELF?poll=$riadok[id_poll]&option=$riadok2[id_option]>$riadok2[text]</a></td><td><table width=$count bgcolor=green height=5><tr height=5><td height=5></tr></td></table></td><td>".$count."% </td></tr>"; |
| 26 | } |
| 27 | echo "</table>"; |
| 28 | } |
| 29 | mysql_close(); |
| 30 | ?> |