投票操作管理系统
来源:互联网 发布:javascript var json 编辑:程序博客网 时间:2024/04/29 23:27
vote.php
poll_vote.php
<html><head> <meta charset="utf-8"> <title>vote</title> <script> function getVote(int) { xmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("poll").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","poll_vote.php?vote="+int,true); xmlhttp.send(); } </script></head><body><div id="poll"> <form> 菊花侠: <input type="radio" name="vote" value="0" onclick="getVote(this.value)"> <br>桃花怪: <input type="radio" name="vote" value="1" onclick="getVote(this.value)"> </form></div></body></html>
poll_vote.php
<?phpheader("Content-type:text/html;charset=utf-8");$vote = htmlspecialchars($_REQUEST['vote']);// 获取文件中存储的数据$fileDir = "poll_result.txt";$content = file_get_contents($fileDir);// 将数据分割到数组中$array = explode("||", $content);$yes = $array[0];$no = $array[1];if ($vote == 0){ $yes+=1;}if ($vote == 1){ $no+=1;}// 插入投票数据$insertvote = $yes."||".$no;$fp = fopen($fileDir,"w");fputs($fp,$insertvote);fclose($fp);?><h2>投票结果:</h2><table> <tr> <td>菊花侠:</td> <td> <span style="display: inline-block; background-color:green; width:<?php echo(100*round($yes/($no+$yes),2)); ?>px; height:20px;" ></span> <?php echo(100*round($yes/($no+$yes),2)); ?>% </td> </tr> <tr> <td>桃花怪:</td> <td> <span style="display: inline-block; background-color:red; width:<?php echo(100*round($no/($no+$yes),2)); ?>px; height:20px;"></span> <?php echo(100*round($no/($no+$yes),2)); ?>% </td> </tr></table>
0 0
- 投票操作管理系统
- 投票操作管理系统
- 投票管理系统
- 投票管理系统
- 投票管理系统的数据库表设计
- 第08章 投票管理系统
- C语言实现电子投票管理系统
- 投票系统投票界面
- 投票系统
- 投票系统
- 投票系统
- 投票管理系统案例-Java Web开发实例
- 2016暑假实习项目之微信投票管理系统
- 微信投票管理系统(三)E-R图
- 2016暑假实习项目之微信投票管理系统
- 微信投票管理系统(二)对系统进行分析
- 投票系统饼状图
- 明星投票系统
- 最新 Android屏幕适配全攻略(官方权威适配方案)
- awakeFromNib方法中的注意
- 大型网站技术架构
- Java 集合:Collection,List,ArrayList,Vector,LinkedList(实现方式,对比)
- oracle ebs 采购订单导入 来源参考 Oracle metalink
- 投票操作管理系统
- iOS开发--NSDate与NSDateFormatter的相关用法【转】
- X86&&X64 汇编学习——内联基础
- [编程题]最大子方阵
- 常用正则表达式
- 【Struts 2】Struts2环境搭建
- 视频背景抠图(opencv)
- Canal--------阿里巴巴开源项目: 基于mysql数据库binlog的增量订阅&消费
- [LeetCode] 43. Multiply Strings