Php survey system 2_PHP tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.