PHP Comment ballot box _php tutorial for personal home page use

Source: Internet
Author: User
It is useful for moderators to see whether their homepage is popular, what is popular, and what needs to be improved. Put an opinion ballot box on your homepage to collect the views of visitors in time, which will greatly help the construction of the website. Here is a comment ballot box page written in PHP, which will be refreshed on this page after each poll, showing the number of votes and the percentage of each.

----------------------vote.php------------------------------


<title>Would you please vote</title>



if (Isset ($Submit))//If new content is submitted
{
if (!file_exists ("Voterec.txt"))
{
The number of votes is 0.
$voterec = Array (0, 0, 0, 0, 0);
}
Else
{
Read the voting records
$voterec = File ("Voterec.txt");
}
Update voting records
$voterec [$vote-1] + = 1;
Write a new poll record
$fp = fopen ("Voterec.txt", "w+");
$total = 0;
for ($i = 0; $i < 5; $i + +)
{
$voterec [$i] = Chop ($voterec [$i]);
$total + = $voterec [$i];
Fwrite ($fp, $voterec [$i]. "");
}
Fclose ($FP);
}
?>



http://www.bkjia.com/PHPjc/532200.html www.bkjia.com true http://www.bkjia.com/PHPjc/532200.html techarticle It is useful for moderators to see whether their homepage is popular, what is popular, and what needs to be improved. Put an opinion poll on your homepage ...

  • 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.