<?
#########################################################
# Simple Poll                                           #
#########################################################
#                                                       #
# Author: CodeMunkyX                                    #
#                                                       #
# This script and all included functions, images,       #
# and documentation are copyright 2003                  #
# free-php.net (http://free-php.net) unless             #
# otherwise stated in the module.                       #
#                                                       #
# Any copying, distribution, modification with          #
# intent to distribute as new code will result          #
# in immediate loss of your rights to use this          #
# program as well as possible legal action.             #
#                                                       #
#########################################################

include("admin/config.inc.php");
include("admin/functions.inc.php");

$simplepollurl = simplepollurl;

connect();

$pollid      = $_REQUEST['pollid'];

$sql_result = query("SELECT * FROM poll WHERE id = '$pollid'");


if (isset($sql_result)) {

 $numpolls = num_rows($sql_result);

 for ($i=0; $i<$numpolls; $i++) {

	 $row=fetch($sql_result);

	 $numpollvotes = $row[votes];

	 $pollquestion    = $row[question];
	 $pollname        = $row[name];

	 $pollbgcolor     = $row[bgcolor];
	 $pollfontsize    = $row[fontsize];
	 $pollfont        = $row[font];
	 $pollfontcolor   = $row[fontcolor];

	 $polltfontsize   = $row[tfontsize];
	 $polltfont       = $row[tfont];
	 $polltfontcolor  = $row[tfontcolor];
	 $polltbgcolor    = $row[tbgcolor];
 }
}

$sql_result = query("SELECT * FROM choices WHERE pollid = '$pollid'");


if (isset($sql_result)) {

 $numpolls = num_rows($sql_result);

 for ($i=0; $i<$numpolls; $i++) {

	 $row=fetch($sql_result);

    $width   = ($row[votes]/$numpollvotes)*200;
    $percent = ($row[votes]/$numpollvotes)*100;

    $pollresult .= '
             <table width="100%" border="0" cellspacing="0" cellpadding="3">
              <tr>
                <td width="79%"><font color="'.$pollfontcolor.'" size="'.$pollfontsize.'" face="'.$pollfont.'">'.$row[choice].'</font></td>
                <td width="21%" align="center"><font color="'.$pollfontcolor.'" size="'.$pollfontsize.'" face="'.$pollfont.'">'.$row[votes].'</font></td>
              </tr>
              <tr>
                <td><table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="10"><img src="'.$simplepollurl.'/trans.gif" width="1" height="1"></td>
                    <td bgcolor="'.$row[barcolor].'"><img src="'.$simplepollurl.'/trans.gif" width="'.$width.'" height="8"></td>
                  </tr>
                </table></td>
                <td align="center"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">'.$percent.'%</font></td>
              </tr>
              <tr>
                <td><img src="'.$simplepollurl.'/trans.gif" width="8" height="8"></td>
                <td align="center"><img src="'.$simplepollurl.'/trans.gif" width="1" height="1"></td>
              </tr>
            </table>';
 }
}

close();

eval("dooutput(\"".gettemplate(templatedir,"poll_results")."\");");

?>