首页 > Web开发 > 详细

PHP ajax投票反馈

时间:2016-03-27 13:57:37      阅读:251      评论:0      收藏:0      [点我收藏+]
<?php
$vote = $_REQUEST[‘vote‘];
//get content of textfile
$filename = "poll_result.txt";
$content = file($filename);
//put content in array
$array = explode("||", $content[0]);
$yes = $array[0];
$no = $array[1];
if ($vote == 0)
{
$yes = $yes + 1;
}
if ($vote == 1)
{
$no = $no + 1;
}
//insert votes to txt file
$insertvote = $yes."||".$no;
$fp = fopen($filename,"w");
fputs($fp,$insertvote);
fclose($fp);
?>
<h2>Result:</h2>
<table>
<tr>
<td>Yes:</td>
<td>
<div style="width:100;background-color:#000;height:10;">
<div style="background-color:#FF6600;width:<?php echo(100*round($yes/($no+$yes),2)); ?>;height:10;"></div>
</div>
<?php echo(100*round($yes/($no+$yes),2)); ?>%
</td>
</tr>
<tr>
<td>No:</td>
<td>
<div style="width:100;background-color:#000;height:10;">
<div style="background-color:#FF6600;width:<?php echo(100*round($no/($no+$yes),2)); ?>;height:10;"></div>
</div>
<?php echo(100*round($no/($no+$yes),2)); ?>%
</td>
</tr>
</table>

  

PHP ajax投票反馈

原文:http://www.cnblogs.com/wkaifa/p/5325323.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!