PHP 投票练习
2016-05-10 11:27
316 查看
重点: 1、进度条的显示 2、操作数据库 <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} </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>
相关文章推荐
- PHP,单项查询及多项查询
- 使用XHProf查找PHP性能瓶颈
- PHP 增删改查 import!!
- PHP 数据访问
- 深入理解浏览器会话机制(session && cookie)
- PHP 对象及其三大特性
- Only one AsyncAnnotationBeanPostProcessor may exist within the context.
- Yii2.0 实现RESTful风格的简单API
- php第十五节课
- php实现上传图片和等比例缩略图压缩图片
- thinkphp 分组、页面跳转与ajax
- thinkphp 分组、页面跳转与ajax
- thinkphp 分组、页面跳转与ajax
- PHP正则提取HTML中img的url值
- php+mysql实现的二级联动菜单效果详解
- parent:: self:: static $this->php
- static 关键字static2.php
- 使用FileZilla Server轻松搭建个人FTP服务器
- sftp的安装配置
- php实现登录注册功能