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