php 数据访问练习:投票页面

<!--投票界面-->

<html>
<head>
<title></title>
<meta charset="UTF-8"/>

<link rel="stylesheet" type="text/css" href="bootstrap.min.css"/>
<script src="bootstrap.min.js"></script>
<script src="jquery-1.11.2.min.js"></script>

<style type="text/css">
*{
margin: 0px auto;
padding: 0px;
}
.wid{
max-width: 300px;
}
.zhezhao{
height: 260px;
width: 321px;
background-color: white;
/*border: 1px solid;*/
position: absolute;
top: 149px;
left: 519px;
}
.fanhui{
position: absolute;
top: 418px;
left: 237px;
height: 39px;
width: 150px;
/*border: 1px solid;*/
background-color: white;
}
</style>
</head>

<form action="tianjia.tp.php" method="post">
<body>
<div style="height: 50px;"></div>

<?php
$da = new MySQLi("localhost","root","","php_zuoye");
$sql = "select numbers from diaoyanxuanxiang";
$result = $da->query($sql);
$arr = $result->fetch_all();

foreach($arr as $v){
$z[] = $v[0];
}

$a1 = $z[0]/($z[0]+$z[1]+$z[2]+$z[3]+$z[4])*100;
$a1 = round($a1);

$a2 = $z[1]/($z[0]+$z[1]+$z[2]+$z[3]+$z[4])*100;
$a2 = round($a2);

$a3 = $z[2]/($z[0]+$z[1]+$z[2]+$z[3]+$z[4])*100;
$a3 = round($a3);

$a4 = $z[3]/($z[0]+$z[1]+$z[2]+$z[3]+$z[4])*100;
$a4 = round($a4);

$a5 = $z[4]/($z[0]+$z[1]+$z[2]+$z[3]+$z[4])*100;
$a5 = round($a5);



?>

<div class="panel panel-primary" style="max-width: 900px;">
<div class="panel-heading">
<h3 class="panel-title">调查问卷</h3>
</div>
<div class="panel-body">
<label for="name">一、晚上回家干什么</label>
<div class="checkbox" >
<label><input type="checkbox" name="wt1[0]" value="1"
id="kds">
看电视
</label>

<?php
echo "
<div class='progress progress-striped wid'
style='position: relative;'><!--进度条-->
<div class='progress-bar progress-bar-info' role='progressbar'
aria-valuenow='60' aria-valuemin='0' aria-valuemax='100'
style='width:
{$a1}%;'>
</div>
<span style='right:136px; position: absolute;'>
{$a1}%
</span>
</div>";
?>
</div>
<div class="checkbox">
<label><input type="checkbox" name="wt1[1]" value="2"
id="wyx">
玩游戏
</label>

<?php
echo "
<div class='progress progress-striped wid'
style='position: relative;'><!--进度条-->
<div class='progress-bar progress-bar-info' role='progressbar'
aria-valuenow='60' aria-valuemin='0' aria-valuemax='100'
style='width: {$a2}%;'>
</div>
<span style='right:136px; position: absolute;'>
{$a2}%
</span>
</div>"
?>
</div>
<div class="checkbox">
<label><input type="checkbox" name="wt1[2]" value="3"
id="js">
健身
</label>

<?php
echo "
<div class='progress progress-striped wid'
style='position: relative;'><!--进度条-->
<div class='progress-bar progress-bar-info' role='progressbar'
aria-valuenow='60' aria-valuemin='0' aria-valuemax='100'
style='width: {$a3}%;'>
</div>
<span style='right:136px; position: absolute;'>
{$a3}%
</span>
</div>"
?>
</div>
<div class="checkbox">
<label><input type="checkbox" name="wt1[3]" value="4"
id="xzy">
写作业
</label>

<?php
echo "
<div class='progress progress-striped wid'
style='position: relative;'><!--进度条-->
<div class='progress-bar progress-bar-info' role='progressbar'
aria-valuenow='60' aria-valuemin='0' aria-valuemax='100'
style='width: {$a4}%;'>
</div>
<span style='right:136px; position: absolute;'>
{$a4}%
</span>
</div>"
?>
</div>
<div class="checkbox">
<label><input type="checkbox" name="wt1[4]" value="5"
id="gdx">
搞对象
</label>

<?php
echo "
<div class='progress progress-striped wid'
style='position: relative;'><!--进度条-->
<div class='progress-bar progress-bar-info' role='progressbar'
aria-valuenow='60' aria-valuemin='0' aria-valuemax='100'
style='width: {$a5}%;'>
</div>
<span style='right:136px; position: absolute;'>
{$a5}%
</span>
</div>"
?>
</div>

<div>
<button type="submit" class="btn btn-primary" id="tijiao"
οnclick="return tishi()">
投 票
</button>
<button type="button" class="btn btn-primary"
id="chakan" οnclick="set(zhezhao),remove(fanhui)">
查看结果
</button>
</div>
</div>

<div class="zhezhao" id="zhezhao" style="">

</div>

<div id="fanhui" class="fanhui" style="display: none;">
<button type="button" class="btn btn-primary"
style="width: 100px;" οnclick="remove(zhezhao),set(fanhui)">
返 回
</button>
</div>
</div>

</body>
</form>
</html>
<script type="text/javascript">
var zhezhao = document.getElementById("zhezhao");
var chakan = document.getElementById("chakan");
var fanhui = document.getElementById("fanhui");
var kds = document.getElementById("kds");
var wyx = document.getElementById("wyx");
var js = document.getElementById("js");
var xzy = document.getElementById("xzy");
var gdx = document.getElementById("gdx");

function set(zz){
zz.style.setAttribute("display","none");
}
function remove(zzz){
zzz.style.removeAttribute("display");
}
function tishi(){
if(!kds.checked && !wyx.checked && !js.checked && !xzy.checked && !gdx.checked){
alert("请选择投票选项!");
return false;
}else{
alert("投票成功!");
return true;
}
}
</script>

<!--投票处理界面-->

<?php
header("Content-type:text/html;charset=utf-8");

$arr = $_POST["wt1"];

$db = new MySQLi("localhost","root","","php_zuoye");
if(mysqli_connect_error()){
echo "lianjieshibai";
}
$sql = "update diaoyanxuanxiang set
numbers = numbers + 1 where ids='{$arr[0]}'|| ids='{$arr[1]}'
|| ids='{$arr[2]}'|| ids='{$arr[3]}'|| ids='{$arr[4]}'";

if($db->query($sql)){
header("location:toupiao.php");
}else{
echo "失败";
}
?>

转载于:https://www.cnblogs.com/liuyuze/p/7481810.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/391440.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

深入理解InnoDB(3)—索引的存储结构

1. 索引的各种存储结构及其优缺点 1.1 二叉树 优点&#xff1a; 二叉树是一种比顺序结构更加高效地查找目标元素的结构&#xff0c;它可以从第一个父节点开始跟目标元素值比较&#xff0c;如果相等则返回当前节点&#xff0c;如果目标元素值小于当前节点&#xff0c;则移动到左…

有抱负/初级开发人员的良好习惯-避免使用的习惯

When youre learning to code, it can be easy to pick up some nasty habits along the way. Here are some tips to avoid common bad habits, and the good habits to keep in mind.当您学习编码时&#xff0c;很容易在此过程中养成一些讨厌的习惯。 这里有一些技巧&#xf…

业精于勤荒于嬉---Go的GORM查询

查询 //通过主键查询第一条记录 db.First(&user)SELECT * FROM users ORDER BY id LIMIT 1;// 随机取一条记录 db.Take(&user)SELECT * FROM users LIMIT 1;// 通过主键查询最后一条记录 db.Last(&user)SELECT * FROM users ORDER BY id DESC LIMIT 1;// 拿到所有的…

apache 虚拟主机详细配置:http.conf配置详解

Apache的配置文件http.conf参数含义详解 Apache的配置由httpd.conf文件配置&#xff0c;因此下面的配置指令都是在httpd.conf文件中修改。主站点的配置(基本配置) (1) 基本配置:ServerRoot "/mnt/software/apache2" #你的apache软件安装的位置。其它指定的目录如果没…

深入理解InnoDB(4)—索引使用

1. 索引的代价 在了解索引的代价之前&#xff0c;需要再次回顾一下索引的数据结构B树 如上图&#xff0c;是一颗b树&#xff0c;关于b树的定义可以参见B树&#xff0c;这里只说一些重点&#xff0c;浅蓝色的块我们称之为一个磁盘块&#xff0c;可以看到每个磁盘块包含几个数据…

[BZOJ1626][Usaco2007 Dec]Building Roads 修建道路

1626: [Usaco2007 Dec]Building Roads 修建道路 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 1730 Solved: 727 [Submit][Status][Discuss]Description Farmer John最近得到了一些新的农场&#xff0c;他想新修一些道路使得他的所有农场可以经过原有的或是新修的道路互达…

双城记s001_双城记! (使用数据讲故事)

双城记s001Keywords: Data science, Machine learning, Python, Web scraping, Foursquare关键字&#xff1a;数据科学&#xff0c;机器学习&#xff0c;Python&#xff0c;Web抓取&#xff0c;Foursquare https://br.pinterest.com/pin/92816442292506979/https://br.pintere…

python:linux中升级python版本

https://www.cnblogs.com/gne-hwz/p/8586430.html 转载于:https://www.cnblogs.com/gcgc/p/11446403.html

web前端面试总结

2019独角兽企业重金招聘Python工程师标准>>> 摘要&#xff1a;前端的东西特别多&#xff0c;面试的时候我们如何从容应对&#xff0c;作为一个老兵&#xff0c;我在这里分享几点我的经验。 一、javascript 基础(es5) 1、原型&#xff1a;这里可以谈很多&#xff0c;…

783. 二叉搜索树节点最小距离(dfs)

给你一个二叉搜索树的根节点 root &#xff0c;返回 树中任意两不同节点值之间的最小差值 。 注意&#xff1a;本题与 530&#xff1a;https://leetcode-cn.com/problems/minimum-absolute-difference-in-bst/ 相同 示例 1&#xff1a; 输入&#xff1a;root [4,2,6,1,3] 输…

linux epoll机制对TCP 客户端和服务端的监听C代码通用框架实现

1 TCP简介 tcp是一种基于流的应用层协议&#xff0c;其“可靠的数据传输”实现的原理就是&#xff0c;“拥塞控制”的滑动窗口机制&#xff0c;该机制包含的算法主要有“慢启动”&#xff0c;“拥塞避免”&#xff0c;“快速重传”。 2 TCP socket建立和epoll监听实现 数据结构…

linux中安装robot环境

https://www.cnblogs.com/lgqboke/p/8252488.html&#xff08;文中验证robotframework命令应该为 robot --version&#xff09; 可能遇到的问题&#xff1a; 1、python版本太低 解决&#xff1a;升级python https://www.cnblogs.com/huaxingtianxia/p/7986734.html 2、pip安装报…

angular 模块构建_我如何在Angular 4和Magento上构建人力资源门户

angular 模块构建Sometimes trying a new technology mashup works wonders. Both Magento 2 Angular 4 are very commonly talked about, and many consider them to be the future of the development industry. 有时尝试新技术的mashup会产生奇迹。 Magento 2 Angular 4都…

tableau破解方法_使用Tableau浏览Netflix内容的简单方法

tableau破解方法Are you struggling to perform EDA with R and Python?? Here is an easy way to do exploratory data analysis using Tableau.您是否正在努力使用R和Python执行EDA&#xff1f; 这是使用Tableau进行探索性数据分析的简单方法。 Lets Dive in to know the …

六周第三次课

2019独角兽企业重金招聘Python工程师标准>>> 六周第三次课 9.6/9.7 awk awk也是流式编辑器&#xff0c;针对文档中的行来操作&#xff0c;一行一行地执行。 awk比sed更强大的功能是它支持了分段。 -F选项的作用是指定分隔符&#xff0c;如果不加-F选项&#xff0c;…

面试题字符集和编码区别_您和理想工作之间的一件事-编码面试!

面试题字符集和编码区别A recruiter calls you for a position with your dream company. You get extremely excited and ask about their recruiting process. He replies saying “Its nothing big, you will have 5 coding rounds with our senior tech team, just the sta…

初探Golang(1)-变量

要学习golang&#xff0c;当然要先配置好相关环境啦。 1. Go 安装包下载 https://studygolang.com/dl 在Windows下&#xff0c;直接下载msi文件&#xff0c;在安装界面选择安装路径&#xff0c;然后一直下一步就行了。 在cmd下输入 go version即可看到go安装成功 2. Golan…

macaca web(4)

米西米西滴&#xff0c;吃过中午饭来一篇&#xff0c;话说&#xff0c;上回书说道macaca 测试web&#xff08;3&#xff09;&#xff0c;参数驱动来搞&#xff0c;那么有小伙本又来给雷子来需求&#xff0c; 登录模块能不能给我给重新封装一下吗&#xff0c; 我说干嘛封装&…

linux中安装cx_Oracle

https://blog.csdn.net/w657395940/article/details/41144225 各种尝试都&#xff0c;最后 pip install cx-Oracle 成功导入 转载于:https://www.cnblogs.com/gcgc/p/11447583.html

rfm模型分析与客户细分_如何使用基于RFM的细分来确定最佳客户

rfm模型分析与客户细分With some free time at hand in the midst of COVID-19 pandemic, I decided to do pro bono consulting work. I was helping a few e-commerce companies with analyzing their customer data. A common theme I encountered during this work was tha…