View file vote_answer.php

File size: 2.65Kb
<?php
require('includes/header.php');
require('includes/utils.php');
require('includes/db.php');

$max_pages = 5;

if(isset($_POST['answer']))
{
   mysql_query('UPDATE polls_answers SET votes = votes + 1 WHERE qid = "' . (int)$_GET['vote_id'] . '" AND aid = "' . (int)$_POST['answer'] . '"');
?>
<wml>
<card id="added" title="added" ontimer="vote.php?login=<?php echo $_GET['login']; ?>&amp;vote_id=<?php echo $_GET['vote_id']; ?>"><timer value="15"/>
<p>
Ваш голос принят<br/>
</p>
</card>
</wml>
<?php
   exit;
}
?>
<wml>
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
<card id="links" title="&#x041C;&#x0435;&#x043D;&#x0435;&#x0434;&#x0436;&#x0435;&#x0440; &#x0444;&#x0430;&#x0439;&#x043B;&#x043E;&#x0432;">
<do type="options" name="main" label="&#x041C;&#x0435;&#x043D;&#x044E;"><go href="<?php echo $_GET['login']; ?>/index.wml"/></do>
<p>
<?php
   $links_list = '';

   $login = addslashes($_GET['login']);
   $links = mysql_query('SELECT l.id as id, l.question as question, l.date as date FROM polls_questions l, users u WHERE u.login = "' . $login . '" AND u.id = l.user_id AND l.id = "' . (int)$_GET['vote_id'] . '" LIMIT 1');

   $months = array('января', 'февраля', 'марта', 'апреля', 'мая', 'июня',                        'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря');
   if(($n = mysql_num_rows($links)) > 0)
   {
      while($link = mysql_fetch_array($links, MYSQL_ASSOC))
      {
         $links_list .= "$link[question]\n<br/>\n";
      }
   }

   $links = mysql_query('SELECT sum(votes) FROM polls_answers WHERE qid = "' . (int)$_GET['vote_id'] . '"');
   list($total_votes) = mysql_fetch_array($links);

   $links = mysql_query('SELECT l.aid as aid, l.answer as answer, l.votes as votes FROM polls_answers l WHERE l.qid = "' . (int)$_GET['vote_id'] . '" ORDER by aid');

   $links_list .= '<select name="answer" multiple="false" ivalue="1">';

   while($link = mysql_fetch_array($links, MYSQL_ASSOC))
   {
      $links_list .= "<option value=\"$link[aid]\">$link[answer]</option>\n";
   }
   $links_list .= '</select>';
?>
<br/>
<?php echo $links_list; ?>
<br/>
<br/>
<anchor title="ДА">Голосуем
<postfield name="answer" value="$(answer)"/>
<go href="vote_answer.php?login=<?php echo $_GET['login']; ?>&amp;vote_id=<?php echo $_GET['vote_id']; ?>" method="post">
</go>
</anchor>
<br/>------<br/>
<a href="votes.php?login=<?php echo $_GET['login']; ?>">&lt;&lt;Все опросы</a>
<br/>
<a href="<?php echo $_GET['login']; ?>/">&lt;&lt;На главную</a>
</p>
</card>
</wml>