Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > Yuna Scatari Edition (YSE)
Reply
  #1  
Old 17th December 2010, 16:02
Tmx Tmx is offline
Member
 
Join Date: Dec 2009
Latvia
Posts: 11
Default Problem with poll
Hi, i have small problem with poll
I can't vote in poll.... when i vote it not show a result!

and there is my poll.php

Code:
<?php
if (!defined('BLOCK_FILE')) {
 Header("Location: ../index.php");
 exit;
}

global $CURUSER, $tracker_lang, $ss_uri;

  // Get current poll
  $res = sql_query("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
  if($pollok=(mysql_num_rows($res))) {
          $arr = mysql_fetch_assoc($res);
          $pollid = $arr["id"];
          $userid = $CURUSER["id"];
          $question = $arr["question"];
          $o = array($arr["option0"], $arr["option1"], $arr["option2"], $arr["option3"], $arr["option4"],
            $arr["option5"], $arr["option6"], $arr["option7"], $arr["option8"], $arr["option9"],
            $arr["option10"], $arr["option11"], $arr["option12"], $arr["option13"], $arr["option14"],
            $arr["option15"], $arr["option16"], $arr["option17"], $arr["option18"], $arr["option19"]);

  // Check if user has already voted
          $res = sql_query("SELECT * FROM pollanswers WHERE pollid=$pollid AND userid=$userid") or sqlerr(__FILE__, __LINE__);
          $arr2 = mysql_fetch_assoc($res);
  }

  $blocktitle = $tracker_lang['poll'].(get_user_class() >= UC_MODERATOR ? "<font class=\"small\"> - [<a class=\"altlink\" href=\"makepoll.php?returnto=main\"><b>".$tracker_lang['create']."</b></a>]".($pollok ? " - [<a class=\"altlink\" href=\"makepoll.php?action=edit&pollid=$arr[id]&returnto=main\"><b>Labot</b></a>] - [<a class=\"altlink\" href=\"polls.php?action=delete&pollid=$arr[id]&returnto=main\"><b>Dzēst</b></a>]" : "")."</font>" : "");

        if($pollok) {
          $content .= ("<p align=\"center\"><b>$question</b></p>\n");
          $voted = $arr2;
          if ($voted) {
            // display results
            if ($arr["selection"])
              $uservote = $arr["selection"];
            else
              $uservote = -1;
                        // we reserve 255 for blank vote.
            $res = sql_query("SELECT selection FROM pollanswers WHERE pollid=$pollid AND selection < 20") or sqlerr(__FILE__, __LINE__);

            $tvotes = mysql_num_rows($res);

            $vs = array(); // array of
            $os = array();

            // Count votes
            while ($arr2 = mysql_fetch_row($res))
              $vs[$arr2[0]] += 1;

            reset($o);
            for ($i = 0; $i < count($o); ++$i)
              if ($o[$i])
                $os[$i] = array($vs[$i], $o[$i]);

            function srt($a,$b) {
              if ($a[0] > $b[0]) return -1;
              if ($a[0] < $b[0]) return 1;
              return 0;
            }

            // now os is an array like this: array(array(123, "Option 1"), array(45, "Option 2"))
            if ($arr["sort"] == "yes")
                usort($os, srt);

            $content .= ("<table class=\"main\" align=\"center\" width=\"250\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n");
            $i = 0;
            while ($a = $os[$i]) {
              if ($i == $uservote)
                $a[1] .= "&nbsp;*";
              if ($tvotes == 0)
                      $p = 0;
              else
                      $p = round($a[0] / $tvotes * 100);
              if ($i % 2)
                $c = "";
              else
                $c = " bgcolor=\"#eeeeee\"";
              $content .= ("<tr><td width=\"1%\" class=\"embedded\"$c><nobr>" . $a[1] . "&nbsp;&nbsp;</nobr></td><td width=\"99%\" class=\"embedded\"$c><nobr>" .
                "<img src=\"./themes/$ss_uri/images/bar_left.gif\"><img src=\"./themes/$ss_uri/images/bar.gif\" height=\"12\" width=\"" . ($p * 3) .
                "\"><img src=\"./themes/$ss_uri/images/bar_right.gif\"> $p%</nobr></td></tr>\n");
              ++$i;
            }
            $content .= ("</table>\n");
            $tvotes = number_format($tvotes);
            $content .= ("<p align=\"center\">Votes: $tvotes</p>\n");
          } else {
            $content .= ("<form method=\"post\" action=\"index.php\">\n");
            $i = 0;
            while ($a = $o[$i]) {
              $content .= ("<input type=\"radio\" name=\"choice\" value=\"$i\">$a<br />\n");
              ++$i;
            }
            $content .= ("<br />");
            $content .= ("<input type=\"radio\" name=\"choice\" value=\"255\">".$tracker_lang['blank_vote']."<br />\n");
            $content .= ("<p align=\"center\"><input type=\"submit\" value=\"".$tracker_lang['vote']."\" class=\"btn\"></p>");
            $content .= ("</form>");
          }
        if ($voted)
          $content .= ("<div align=\"center\"><a href=\"polls.php\">".$tracker_lang['old_polls']."</a></div>\n");
        } else {
            $content .= "<table class=\"main\" align=\"center\" border=\"1\" cellspacing=\"0\" cellpadding=\"10\"><tr><td class=\"text\">";
            $content .= "<div align=\"center\"><h3>".$tracker_lang['no_polls']."</h3></div>\n";
            $content .= "</td></tr></table>";
        }
?>

Last edited by Tmx; 17th December 2010 at 16:36.
Reply With Quote
  #2  
Old 17th December 2010, 20:01
mat22 mat22 is offline
Senior Member
 
Join Date: Jun 2009
Latvia
Posts: 119
Default
I have same problem. Everything worked fine before i turned on blocks system. But it works fine on clean source without my modding. Where's problem?
Reply With Quote
Reply

Tags
poll , problem

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 22:50. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.