zoukankan      html  css  js  c++  java
  • PHP投票练习

    <!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" />
    <style type="text/css">
    .x
    {
    	float:left;
    }
    #top
    {
    	500px;
    	height:110px;
    }
    #bottom
    {
    	500px;
    	height:100px;
    	display:none;
    }
    #fanhui
    {
    	display:none;
    }
    </style>
    <title>无标题文档</title>
    </head>
    
    <body>
    <!--投票页面-->
    <form action="toupiaochuli.php" method="post">
    <?php
    include("DBDA.class.php");
    $db=new DBDA();
    $stm="select * from DiaoYanTiMu limit 0,1";//取第一条
    $atm=$db->Query($stm);
    echo "<div>题目名称:{$atm[0][1]}</div>";
    //$atm[0][0];
    $sxx="select * from DiaoYanXuanXiang where TiMuDaiHao='{$atm[0][0]}'";
    $axx=$db->Query($sxx);
    echo "<div id='top'>";
    foreach($axx as $v)
    {
    	echo"<div><input type='checkbox' value='{$v[0]}' name='xx[]'/>{$v[1]}</div>";
    }
    echo "</div>";
    ?>
    <!--显示结果-->
    <div id="bottom">
    <?php
    $sum="select sum(Numbers) from DiaoYanXuanXiang where TiMuDaiHao='{$atm[0][0]}'";
    $asum=$db->Query($sum);
    $total=$asum[0][0];
    foreach($axx as $v)
    {
    	$bfb=($v[2]/$total)*100;
    	echo "<div ><span class='x'>{$v[1]}</span>
    	<div class='x' style='border:1px solid blue;120px;height:12px'>
    	<div style='background-color:red;height:12px;{$bfb}%'></div></div>
    	<span class='x'> {$v[2]} </span>
    	<span class='x'>{$bfb}%</span>
    	</div>
    	<div style='clear:both'></div>";
    }
    ?>
    </div>
    <div id="anniu"><input type="submit" value="提交"/>
    <input type="button" value="查看" onclick="ShowResult()"/></div>
    <div id="fanhui"><input type="button" value="返回" onclick="Show()"/></div>
    </form>
    
    </body>
    <script type="text/javascript">
    function ShowResult()
    {
    	document.getElementById("top").style.display="none";
    	document.getElementById("bottom").style.display="block";
    	document.getElementById("fanhui").style.display="block";
    	document.getElementById("anniu").style.display="none";
    }
    function Show()
    {
    	document.getElementById("top").style.display="block";
    	document.getElementById("bottom").style.display="none";
    	document.getElementById("fanhui").style.display="none";
    	document.getElementById("anniu").style.display="block";
    }
    </script>
    </html>
    

      

    <?php
    $ids=$_POST["xx"];
    include("DBDA.class.php");
    $db=new DBDA();
    foreach($ids as $v)
    {
    	$sql="update DiaoYanXuanXiang set Numbers=Numbers+1 where ids='{$v}'";
    	$db->Query($sql,0);
    }
    header("location:toupiao.php");
    

      

  • 相关阅读:
    【prufer编码】BZOJ1430 小猴打架
    【费马小定理】BZOJ3260 跳
    【欧拉函数】BZOJ2705: [SDOI2012]Longge的问题
    【卡特兰数】BZOJ1485: [HNOI2009]有趣的数列
    【缩点+拓扑判链】POJ2762 Going from u to v or from v to u?
    【Floyd】BZOJ1491: [NOI2007]社交网络
    【转】对信息学竞赛中调试方法的建议
    【建图+拓扑判环】BZOJ3953: [WF2013]Self-Assembly
    【dfs判负环】BZOJ1489: [HNOI2009]最小圈
    【二分+最小树形图】UVA11865 比赛网络
  • 原文地址:https://www.cnblogs.com/hamilton/p/5602940.html
Copyright © 2011-2022 走看看