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.pswp.cn/news/391440.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/391440.shtml
英文地址,請注明出處:http://en.pswp.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…