Php Survey System 2. Name: showresult. php3 this program is used to view the voting result by phpstudent $ vpollid1; passed the parameter investigation IDrequire (database. php3); $ dbnewdatabase (); $ db-openDefa // name: showresult. php3
// This program is used to view the voting result
// Author: phpstudent
// $ Vpollid = 1; pass the parameter survey ID
Require (database. php3 );
$ Db = new database ();
$ Db-> opendefaconnection connection ();
$ SQL = "SELECT polltitle from poll where pollid =". $ vpollid;
$ Db-> openResultset ($ SQL );
$ Db-> rstNext ();
$ Vpolltitle = $ db-> getItem (1); // Retrieve the survey Title
$ 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 () // extract the text, count, and color of the option
{$ 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 ("not voting ");
Else
{Echo ("survey Title:
". $ Vpolltitle ."
");
Echo (""); // call the 3D pie chart program
Echo ("total current votes:". $ voteTotal. "votes ");
For ($ j = 0; $ j <$ I; $ j ++)
{
Echo ("■ ");
Echo ($ vchiocename [$ j]);
Echo ("");
Echo ($ vchiocenum [$ j]. "");
}
Echo ("");
}
?>
========================================================== ========== // Name: showpie. php3
// Author: phpstudent
// This program is used to view the voting result
// $ VpollData; $ vpollColor; passing parameter voting data string and color string
Require (pie3d. php3); // 3D pie chart class. previously published by the program, you only need to remove the following implementation.
$ Objp = new Pie3d ();
$ Objp-> setDataArray ($ vpollData );
$ Objp-> setColorArray ($ vpollColor );
$ Objp-> DrawPie ();
?>
Users // This program is used to view the voting result // Author: phpstudent // $ vpollid = 1; pass the parameter investigation ID require (database. php3); $ db = new database (); $ db-> openDefa...