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" />
    <title>无标题文档</title>
    <style type="text/css">
    .x
    {
        float:left;
    }
    #top
    {
        width:500px;
        height:150px;
    }
    #bottom
    {
        width:500px;
        height:150px;
        display:none;
    }
    #fanhui
    {
        display:none;}
    </style>
    </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>";
    
    $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 black; 120px; height:12px;'>
            <div style='background-color:red;height:12px;{$bfb}%'>
            </div>
        </div>
        <span class='x'>&nbsp;{$v[2]}&nbsp;</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>
    View Code
    <?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:lianxi.php");
    View Code
  • 相关阅读:
    (15)树莓派系统安装和备份
    (0-0) 树莓派学习资料
    (14)树莓派
    (0-1) 树莓派常用软件及服务
    (13)flask搭建服务器
    (12)树莓派串口通信
    OpenCV 学习笔记(0)两幅图像标定配准
    OpenCV 学习笔记(9)RGB转换成灰度图像的一个常用公式Gray = R*0.299 + G*0.587 + B*0.114
    OpenCV 学习笔记(8)彩色图像RGB通道的分离、合并与显示
    Arduino OV7670 live image over USB to PC
  • 原文地址:https://www.cnblogs.com/bilibiliganbei/p/5595889.html
Copyright © 2011-2022 走看看