分两个页面,要点:提交form 相连action method  两个页面可以合成一个页面action传到自身页面   但分开较清晰

第一个页面vote.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">
*
{
margin:0px auto;
padding:0px;
}
h3
{
margin:10px;
}
.diyiceng
{
height:220px;
width:200px;
background-color:#FFF;
position:absolute;
visibility:visible;
left:10px;
top:40px;
}
.dierceng
{
height:220px;
width:800px;
background-color:#FFF;
position:absolute;
visibility:hidden;
left:0px;
top:0px;
}
.xuanxiang
{
position:absolute;
}
.jindu
{
width:200px;
height:10px;
position:absolute;
left:100px;
border:solid #999 1px;
}
.jindutiao
{ height:8px;
position:absolute;
background-color:#0F0;
border:solid 1px #00FF00;
}
.shuzi
{
position:absolute;
left:320px;
}
.baifenbi
{
position:absolute;
left:350px;
}
</style>
</head> <body> <h3>35岁发展方向</h3> <div class="diyiceng" id="diyiceng">
<form action="votechuli.php" method="post">
<?php $db=new mysqli("localhost","root","123","test2");
!mysqli_connect_error()or die("连接错误"); $sql="select * from DiaoYanXuanXiang";
$resulttp=$db->query($sql); while($row = $resulttp->fetch_row())
{ //print_r($row);
echo "<div><input type='checkbox' name='test[]' value='".$row[0]."'/>".$row[1]."</div><br />";
} ?> <input type="submit" name="submit" value="提交" />&nbsp;&nbsp;
<input type="button" name="chakan" value="查看结果" onclick="xianshi()"/>
</form>
<?php
$db=new mysqli("localhost","root","123","test2");
!mysqli_connect_error()or die("连接错误"); $sql="select * from DiaoYanXuanXiang";
$result=$db->query($sql); echo "<div class='dierceng' id='yincang'>";
echo "<form>"; $sqlsum = "select SUM(numbers) from DiaoYanXuanXiang";
$resultsum = $db->query($sqlsum);
$aa = $resultsum->fetch_row();
$zongshu = $aa[0]; while($rowjg = $result->fetch_row())
{
$xuanxiang = $rowjg[1];
$shuliang = $rowjg[2];
$baifenbi = $shuliang/$zongshu*100;
$baifenbi1=round($baifenbi,1);//对小数取一位 echo "<div><div class='xuanxiang'>".$xuanxiang."</div>
<div class='jindu'><div class='jindutiao' style='width:".$baifenbi."%'></div></div>
<div class='shuzi'>".$shuliang."</div>
<div class='baifenbi'>".$baifenbi1."%</div></div><br /><br />";
} echo "<input type='button' name='fanhui' value='返回' onclick='buxianshi()' />";
echo "</form>";
echo "</div></div>"; ?>
</body>
</html>
<script>
function xianshi()
{
var a=document.getElementById("yincang");
if(a.style.visibility="hidden")
{
a.style.visibility="visible";
} }
function buxianshi()
{
var a=document.getElementById("yincang");
if(a.style.visibility="visible")
{
a.style.visibility="hidden";
} } </script>

效果图:

第二个页面

votechuli.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>
</head> <body>
<?php
$test=$_POST["test"]; //1.造连接对象
$db=new mysqli("localhost","root","123","test2");
//2.判断是否连接成功
!mysqli_connect_error()or die("连接失败"); for($i=0;$i<count($test);$i++)
{
$sql="update DiaoYanXuanXiang set numbers=numbers+1 where ids='".$test[$i]."'"; $result=$db->query($sql);//为什么query后要加($sql,0)1代表增删改 变化的一面 0代表 查询 不变的一面 } //判断是否修改成功
if($result)
{
header("Location:vote.php");
}
else
{
echo "修改失败!";
} ?>
</body>
</html>

效果图:

2016/3/30 ①投票checkbox ②进度条两个div套起百分比控制内div(width) <div><div></div></div> ③数据库test2 表 diaoyan... 35岁发展方向投票的更多相关文章

  1. ionic 横向滚动 ion-scroll 进度条(步骤)// 根据后台数据控制当前默认滑动到的位置

    <ion-scroll zooming="false" direction="x" style="width: 100%;" scro ...

  2. Android 自学之进度条ProgressBar

    进度条(ProgressBar)也是UI界面中的一种非常使用的组件,通常用于向用户显示某个耗时完成的百分比.因此进度条可以动态的显示进度,因此避免长时间地执行某个耗时操作时,让用户感觉程序失去了响应, ...

  3. Android 自定义view --圆形百分比(进度条)

    转载请注明出处:http://blog.csdn.net/wingichoy/article/details/50334595 注:本文由于是在学习过程中写的,存在大量问题(overdraw onDr ...

  4. android多线程进度条

    多线程实现更新android进度条. 实例教程,详细信息我已经注释   android多线程进度条   01package com.shougao.hello; 02 03import android ...

  5. QT中可以用QProgressBar或着QProgressDialog来实现进度条

    QProgressBar的使用 首先在designer中拖一个按钮和进度条部件,按下面初始化 //补充:下面两句写在MainWindow的构造函数里进行初始化 ui->progressBar-& ...

  6. 制作进度条(UISlider)

    怎样判断是否应当使用进度条 用进度条的主要目的是为了用一根管子的充满程度来直观地表示某种数值的百分比,进度条分为可拖动和不可拖动两种. 可拖动进度条和不可拖动进度条的原理几乎是一模一样,唯一的区别是可 ...

  7. JQuery UI进度条——Progressbar

    1.先引入jquery和jquery-ui的js,例子如下: <link href="JqueryUI/jquery-ui.css" rel="stylesheet ...

  8. QT中进度条的使用

    在QT中可以用QProgressBar或着QProgressDialog来实现进度条. QProgressBar的使用 首先在designer中拖一个按钮和进度条部件,按下面初始化 //补充:下面两句 ...

  9. 进度条(ProgressBar)的功能与用法

    进度条也是UI界面中一种非常实用的组件,通常用于向用户显示某个耗时操作完成的的百分比.进度条可以动态的显示进度,因此避免长时间的执行某个耗时的操作,让用户感觉程序失去了响应,从而更好的提高用户界面的友 ...

随机推荐

  1. Python 函数的初识

    1.函数的初识 函数的作用:以功能为导向 减少代码重复 # 函数试编程 # 函数以功能(完成一件事)为导向,登录 注册, # 一个函数就是一个功能,一个函数只能写一个功能 # 何时需要 何时调用,随调 ...

  2. ES6(数据结构)

    一.set 用法 set 对数组进行转化 添加重复元素不会生效 (应用:去重复功能)转化过程不会有数据类型的转换 添加.删除.判断是否存在的方法 2. 读取(遍历)的几种方法 二.WeakSet 与S ...

  3. Web框架下安全漏洞的测试反思

    此文已由作者王婷英授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 在平时的测试中,一般情况下,我们都是比较关注功能业务测试,以及对应的接口测试,很少去关注对应的业务设计上存在 ...

  4. winform中ComboBox控件的简单使用

    在开发winform中用到了ComboBox,但是发现和asp.net中的DropDownList差别比我想象中的大. 给ComboBox添加数据总结的有两种方法(绑定数据库在这里不说): 第一种方法 ...

  5. .net异步编程async和await的讨论收获

    微软官方描述: C# 5 引入了一种简便方法,即异步编程.此方法利用了 .NET Framework 4.5 及更高版本..NET Core 和 Windows 运行时中的异步支持. 编译器可执行开发 ...

  6. POJ-3468A Simple Problem with Integers,线段数区间更新查询,代码打了无数次还是会出错~~

    A Simple Problem with Integers Time Limit: 5000MS   Memory Limit: 131072K                Case Time L ...

  7. bzoj1059:[ZJOI2007]矩阵游戏【二分图匹配】

    Description 小Q是一个非常聪明的孩子,除了国际象棋,他还很喜欢玩一个电脑益智游戏——矩阵游戏.矩阵游戏在一个N*N黑白方阵进行(如同国际象棋一般,只是颜色是随意的).每次可以对该矩阵进行两 ...

  8. BZOJ2662[BeiJing wc2012]冻结【SPFA】

    “我要成为魔法少女!” “那么,以灵魂为代价,你希望得到什么?” “我要将有关魔法和奇迹的一切,封印于卡片之中„„”        在这个愿望被实现以后的世界里,人们享受着魔法卡片(SpellCard ...

  9. js获取json属性值的两种方法

    1.json.XXX 2.json["XXX"] 第二种方法使用场景,当属性值是变量时.如图所示:

  10. hdu5608:function

    $n^2-3n+2=\sum_{d|i}f(i)$,问$f(i)$前$n$项和. 方法一:直接切入! $S(n)=\sum_{i=1}^{n}f(i)=\sum_{i=1}^{n}(i^2-3i+2- ...