码迷,mamicode.com
首页 > 其他好文 > 详细

第六十二天休息 简单的投票界面

时间:2016-05-08 13:46:08      阅读:252      评论:0      收藏:0      [点我收藏+]

标签:

投票界面代码

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>index</title>
</head>


<body>
<?php
include "function/unionsql-function.php";


if(isset($_POST[‘submit‘])&& isset($_POST[‘atr‘]))
{
    $atr=$_POST[‘atr‘];
    foreach($atr as $i)
    {
        $s3="select number from dy where code=$i[0]";
        $s3=unionsql($s3);
        $s3=$s3[0][0]+1;
        $s4="update dy set number=$s3 where code=$i[0]";
        $s4=unionsql($s4);
    }
}


$ssum="select sum(number) from dy";
$ssum=unionsql($ssum);
$s1="select * from dytitle";
$s1=unionsql($s1);
if($s1[0][2]==1)
    $type="checkbox";
else
    $type="radio";
$s2="select * from dy where titleid={$s1[0][0]}";
$s2=unionsql($s2);
?>


<div>标题:<?php echo $s1[0][1] ?></div>


<div id=‘a‘ style="display:block;">
<form action=‘‘ method=‘post‘>
<?php
echo "<table>";
foreach($s2 as $i)
{
    echo"<tr>
            <td><input type=$type value=‘$i[0]‘ name=‘atr[]‘ /></td>
            <td>$i[1]</td>
        </tr>";
}
echo "</table>";
?>
<input type="submit" value="提交" name="submit" />&nbsp;&nbsp;
<input type="button" value="投票结果" onclick="ck()" />
</form>
</div>


<div id="b" style="display:none;">
<?php
echo "<table>";
foreach($s2 as $i)
{ 
    $snumber="select number from dy where code=$i[0]";
    $snumber=unionsql($snumber);
    $j=round($snumber[0][0]/$ssum[0][0]*100)."%";
    echo"<tr>
            <td>$i[1]</td>
            <td>$i[2]</td>
            <td>
                <div style=‘width:150px; height:10px; background-color:#666;‘>
                    <div style=‘width:{$j}; height:10px; background-color:#F00;‘></div>
                </div>
            </td>
            <td>$j</td>
        </tr>";
}
echo "</table>";
?>
<input type="button" value="返回投票" onclick="fh()" />
</div>
</body>
</html>
<script type="text/javascript">
function ck()
{
    var a=document.getElementById(‘a‘);
    var b=document.getElementById(‘b‘);
    a.style.display="none";
    b.style.display="block";
}
function fh()
{
    document.getElementById("a").style.display="block";
    document.getElementById("b").style.display="none";    
}
</script>

技术分享

技术分享

 

第六十二天休息 简单的投票界面

标签:

原文地址:http://www.cnblogs.com/lovling/p/5470408.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!