php調查系統2

<?php
//名稱:showresult.php3
//本程序用於查看投票結果
//作者:phpstudent
//$vpollid=1; 傳遞參數 調查ID

require(database.php3);

$db = new database();
$db->openDefaultConnection();
$SQL=”SELECT polltitle from poll where pollid=”.$vpollid;
$db->openResultset($SQL);
$db->rstNext();
$vpolltitle=$db->getItem(1); //取出調查標題
$db->closeResultset();

$SQL = “SELECT chioceid,chiocename,chiocenum,chiocecolor from pollchioce where pollid=”.$vpollid;
$db->openResultset($SQL);

$i=0;
$vpollData=” “;
$vpollColor=””;
$voteTotal=0;
$vchiocename=split(“,”,”1,2,3,4,5,6,7,8″);

while($db->rstNext()) //取出選項的文字,計數及顏色
{ $vchiocename[$i]=$db->getItem(2);
if($i==0)
{
$vpollData=$db->getItem(3);
$vpollColor=$db->getItem(4);
}
else
{$vpollData.=”,”;
$vpollData.=$db->getItem(3);
$vpollColor.=”,”;
$vpollColor.=$db->getItem(4);

}
$voteTotal+=$db->getItem(3);
$i++;
};
$vchiocenum=split(“,”,$vpollData);
$vchiocecolor=split(“,”,$vpollColor);
$db->closeResultset();
$db->closeConnection();

if($voteTotal==0)
echo(“尚未投票”);
else
{echo(“調查標題:
“.$vpolltitle.”
“);
echo(““);//調用繪制3D餅圖程序
echo(“目前投票總數:”.$voteTotal.”票,其中”);
for($j=0;$j<$i;$j++)
{
echo(““);
echo($vchiocename[$j]);
echo(“   ”);
echo($vchiocenum[$j].”票”);
}
echo(“”);
}
?>

=================================================<?php
//名稱:showpie.php3
//作者:phpstudent
//本程序用於查看投票結果
//$vpollData;$vpollColor; 傳遞參數投票數據串及顏色串
require(pie3d.php3); //3D餅圖類,以前程序發表過,隻須將後邊的實現去掉
$objp = new Pie3d();
$objp->setDataArray($vpollData);
$objp->setColorArray($vpollColor);
$objp->DrawPie();
?>

You May Also Like