Notice: Undefined variable: poll_name in .....
Сам код таков:
class Poll
{
public static function index()
{
Header::session_starting();
$ip = $_SERVER['REMOTE_ADDR'];
$select_count = Database::query("SELECT `id` FROM `poll`");
$count = $select_count->num_rows;
$rand = rand(1, $count);
$select_right = Database::query("SELECT `poll_id` FROM `poll_ip` WHERE `user_ip`='".$ip."'");
if($select_right->num_rows > 0)
{
$not_poll = array();
while($p = $select_right->fetch_assoc())
{
$not_poll[] = $p['poll_id'];
}
$not_poll = implode(",", $not_poll);
}
if(!isset($not_poll))
{
$select_poll = Database::query("SELECT `po`.`position`,`p`.`name` as `vote_name`, `p`.`id`, `po`.`votes`, `po`.`name` as `poll_option` FROM `poll` as `p` LEFT JOIN `poll_option` as `po` ON `po`.`id_poll` = `p`.`id` WHERE `p`.`id` = '".$rand."' ORDER BY `position`");
$result = "";
while($poll = $select_poll->fetch_assoc())
{
if(!isset($poll_name) or !isset($_SESSION['id_poll']))
{
$poll_name = $poll['vote_name'];
$_SESSION['id_poll'] = $poll['id'];
}
$result .= "<input type='radio' class='poll_option' name='poll_option' value='".$poll['position']."' />".$poll['poll_option']."<br />";
}
$result = "<form action='' method='post' id='poll_form'><p><b>".$poll_name."</b></p>" . $result;
$result .= "<input type='submit' id='poll_submit' value='Голосовать' /></form>";
}
else
{
$select_poll = Database::query("SELECT `po`.`position`,`p`.`name` as `vote_name`, `p`.`id`, `po`.`votes`, `po`.`name` as `poll_option` FROM `poll` as `p` LEFT JOIN `poll_option` as `po` ON `po`.`id_poll` = `p`.`id` WHERE `p`.`id` NOT IN ('".$not_poll."') ORDER BY `position`");
$result = "";
if($select_poll->num_rows > 0)
{
while($poll = $select_poll->fetch_assoc())
{
if(!isset($poll_name) or !isset($_SESSION['id_poll']))
{
$poll_name = $poll['vote_name'];
$_SESSION['id_poll'] = $poll['id'];
}
$result .= "<input type='radio' id='poll_option' name='poll_option' value='".$poll['position']."' />".$poll['option_name']."<br />";
}
$result = "<form action='' method='post' id='poll_form'><p><b>".$poll_name."</b></p>" . $result;
$result .= "<input type='submit' id='poll_submit' value='Голосовать' /></form>";
}
else
{
$select_poll = Database::query("SELECT `po`.`position`,`p`.`name` as `vote_name`, `p`.`id`, `po`.`votes`, `po`.`name` as `poll_option` FROM `poll` as `p` LEFT JOIN `poll_option` as `po` ON `po`.`id_poll` = `p`.`id` WHERE `p`.`id` = '".$rand."' ORDER BY `position`");
$percent = 0;
$div_line = "";
while($poll = $select_poll->fetch_assoc())
{
$percent = $percent + $poll['votes'];
}
while($poll2 = $select_poll->fetch_assoc())
{
$img = 1;
if(!isset($poll_name))
{
$poll_name = $poll2['vote_name'];
}
$pr = $poll2['votes'] / ($percent / 100);
$div_line .= $poll2['option_name'] . " (" . ceil($pr) . ")<br /><div style='width: 100%;'><div style='width: ".$pr."%; background: url(template/images/poll".$img.".gif);'></div></div>";
$img++;
}
$result = "<p><b>".$poll_name."</b></p>" . $result;
}
}
return $result . "<br /><div id='poll_result'></div>";
}
}
94 строка, это переменная $result перед return`om