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">
    #list{ 250px; height:200px}
    #jieguo{ 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='250px; height:30px'>
            <span class='x'>{$name}</span>
            <div class='x' style='100px; height:8px; border:1px solid red'>
            <div style='{$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");
  • 相关阅读:
    C#下载文件代码更新20070920
    判断IP地址是否合法的sql2000使用存储过程跟函数
    百万级SQL分页存储过程
    C#批量重命名文件代码的实现
    单个分页的存储过程
    阿江网站访问统计系统设计构思分析
    c#查询QQ状态是否在线查询代码
    C# public class Person
    C#禁止应用程序的多重运行
    Outlook最小化到托盘的设置方法
  • 原文地址:https://www.cnblogs.com/yy01/p/5470552.html
Copyright © 2011-2022 走看看