投票

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>

<style type="text/css">
#list{ width:250px; height:200px}
#jieguo{ width:250px; height:200px}
.x{float:left}
</style>
</head>

<body>
<form action="chuli.php" method="post">
<?php
include("../DBDA.php");
$db = new DBDA();

$sql = "select * from DiaoYanTiMu limit 0,1";

$attr = $db->Query($sql);

$tmmc = $attr[0][1];
$tmdh = $attr[0][0];

echo "<div>题目名称:{$tmmc}</div>";

$sqlxx = "select * from DiaoYanXuanXiang where TiMuDaiHao = '{$tmdh}'";

$attrxx = $db->Query($sqlxx);
echo "<div id='list'>";
foreach($attrxx as $v)
{
echo "<div>
<input type='checkbox' value='{$v[0]}' name='xx[]' />
<span>{$v[1]}</span>
</div>";
}

?>
<input type="submit" value="提交" />
<input type="button" value="查看结果" id="check" onclick="ShowJieGuo()" />
</form>
</div>
<div id="jieguo" style="display:none">

<?php

$sqlsum ="select sum(Numbers) from DiaoYanXuanXiang where TiMuDaiHao = '{$tmdh}'";
$attrsum = $db->Query($sqlsum);//所有人数

foreach($attrxx as $v)
{
$name = $v[1]; //选项名
$number = $v[2]; //选择该项的人数
$bfb = ($number/$attrsum[0][0])*100;
$bfb = round($bfb,2); //取小数点后两位

echo "<div style='width:250px; height:30px'>
<span class='x'>{$name}</span>
<div class='x' style='width:100px; height:8px; border:1px solid red'>
<div style='width:{$bfb}%; height:8px; background-color:red'></div>
</div>
<span class='x'>{$number}&nbsp;</span>
<span class='x'>{$bfb}%</span>
</div>";
}

?>
<input type="button" value="返回" id="fanhui" onclick="ShowList()" />
</div>
<script type="text/javascript">
function ShowJieGuo()
{
document.getElementById("list").style.display = "none";
document.getElementById("jieguo").style.display = "block";
}
function ShowList()
{
document.getElementById("list").style.display = "block";
document.getElementById("jieguo").style.display = "none";
}
</script>
</body>
</html>

<?php
$attr = $_POST["xx"];
include("../DBDA.php");
$db = new DBDA();

foreach($attr as $v)
{
$sql = "update DiaoYanXuanXiang set Numbers = Numbers+1 where Ids = '{$v}'";
$db->Query($sql,0);
}

header("location:test.php");

最新文章

  1. FreeMarker模板开发指南知识点梳理
  2. PHP Socket实现websocket(一)基本函数介绍
  3. ACM Steps 2.1.8
  4. Linux下的GNU Emacs 24命令_信息竞赛使用_C++
  5. PBOC2.0与PBOC3.0的区别
  6. 第8章 Android数据存储与IO——File存储
  7. Java 实现大整数加减乘除
  8. Python 异常处理
  9. 数据库表反向生成(一) MyBatis-generator与IDEA的集成
  10. 【机器学习实战】第15章 大数据与MapReduce
  11. Java语法细节 - try_finally和set相关
  12. IDEA破解
  13. Redis入门的简单使用
  14. HashMap、Hashtable、ConcurrentHashMap的原理与区别(简述)
  15. rsa证书ssh登陆服务器
  16. ONOS架构-概览
  17. python - 计算器 程序练习
  18. IntelliJ IDEA创建JavaWeb工程及配置Tomcat部署
  19. jdk源码剖析三:锁Synchronized
  20. AJPFX外汇的常见形态

热门文章

  1. JavaScript的原生引用类型
  2. Android应用程序无法读写USB设备的解决方法
  3. P4700 算
  4. 【POJ 2054】 Color a Tree
  5. vue实现全选,反选
  6. hash练习们
  7. [App Store Connect帮助]三、管理 App 和版本(2.7)输入 App 信息:添加 iMessage 信息版 App 的 App 信息
  8. git配置用户信息
  9. Git 标记操作
  10. mailto的使用