• 投票练习题


    <!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>
    </head>
    
    <body>
    <form action="tpchuli.php" method="post">
    <?php
    
    include("./lei/AAA.class.php");
    
    $db=new AAA();
    $sql="select * from diaoyantimu";
    $attr=$db->Query($sql,1);
    foreach($attr as $v){
            echo "<div>{$v[1]}</div>";
            $sxx="select * from diaoyanxuanxiang where timudaihao='{$v[0]}'";
            $axx=$db->Query($sql,1);
            $bs=0;
            if(!empty($_GET['a']))
            {
                $bs=$_GET['a'];
                }
                $s=$bs==1?"none":"block";
                echo "<div id='toupiao' style='display:{$s}'>";
                foreach($axx as $v1){
                    
                    echo "<div><input type'checkbox' name='tp[]' value='{$v1[0]}'>{$v1[1]}</div>";
                    }
                    echo "</div>";
                    $s1=$bs==0?"none":"block";
                    echo "<div id='jieguo' style='displey:{$s1}'></div>";
                    foreach($axx as $v2)
                    {
                        $v2[2];//当前选项的人数
                        //求总人数
                        $szrs="select sum(numbers) from diaoyanxuanxiang where timudaihao='{$v[0]}'";
                        $azrs=$db->Query($szrs);
                        $azrs=0;
                        $bfb=($v2[2]/$azrs[0])*100;
                        echo "
                            <div>
                                {$v2[1]}
                                <div style='px; height:10px; border:1px solid black;'>
                                    <div style='{$bfb}%; height:10px; background-color:red;'></div>
    
                                </div>
                                {$v2[2]} {$bfb}%
                            </div>
                        ";
                    }
                        
            echo "</ div>";
    }
    
    
    ?>
    <input type="submit" value="投票" />
    <input type="button" id="jg" value="查看结果" onclick="showjg()" />
    <input type="button" id="fanhui" value="返回" onclick="showtp()" />
    </form>
    </body>
    </html>
    <script type="text/javascript">
    function showjg()
    {
        document.getElementById("jieguo").style.display="block";
        document.getElementById("toupiao").style.display="none";
        document.getElementById("jg").style.display="none";
        document.getElementById("fanhui").style.display="block";
        
    }
    
    function showtp()
    {
        document.getElementById("jieguo").style.display="none";
        document.getElementById("toupiao").style.display="block";
        document.getElementById("jg").style.display="block";
        document.getElementById("fanhui").style.display="none";
    }
    </script>


    <?php
    $attr = $_POST["tp"];
    
    $str = implode("','",$attr);
    
    $sql = "update diaoyanxuanxiang set numbers = numbers+1 where ids in('{$str}')";
    
    $db = new MySQLi("localhost","root","123","zz");
    $db->query($sql);
    
    header("location:toupiaolianxi.php?a=1");
  • 相关阅读:
    default关键字用法
    【转载】SpringMvc和servlet简单对比介绍
    build模式入门,build模式理解(转载)
    tomcat logs 目录下各日志文件的含义
    @Component, @Repository, @Service,@Controller的区别
    在项目开发时为什么要先写接口,再写实现类?
    java 中static关键字注意事项
    this关键字使用注意事项
    两个对象之前如何建立联系
    html页面监听事件
  • 原文地址:https://www.cnblogs.com/zxl89/p/6040662.html
Copyright © 2020-2023  润新知