<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
-- phpMyAdmin SQL Dump -- version 4.5.1 -- http://www.phpmyadmin.net -- -- Host: 127.0.0.1 -- Generation Time: 2022-03-28 05:42:05 -- 伺服器版本:10.1.13-MariaDB -- PHP Version: 5.6.21 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `a` -- -- -------------------------------------------------------- -- -- 表的結構 `voto` -- CREATE TABLE `voto` ( `id` int(10) NOT NULL, `titleid` int(10) DEFAULT NULL, `item` varchar(50) DEFAULT NULL, `count` int(10) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- 轉存表中的資料 `voto` -- INSERT INTO `voto` (`id`, `titleid`, `item`, `count`) VALUES (24, 1, '張學友', 0), (25, 1, '陳奕迅', 0), (26, 1, '林俊杰', 0), (27, 1, '蕭敬騰', 0), (29, 1, '', 0), (30, 1, 'aaa', 0); -- -- Indexes for dumped tables -- -- -- Indexes for table `voto` -- ALTER TABLE `voto` ADD PRIMARY KEY (`id`); -- -- 在匯出的表使用AUTO_INCREMENT -- -- -- 使用表AUTO_INCREMENT `voto` -- ALTER TABLE `voto` MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=31; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <a href="admin.php" rel="external nofollow" >增刪改查投票的選項</a> <br> <a href="index.php" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >投票給誰呢</a> </body> </html>
<?php ob_start(); //開啟緩衝區 session_start(); header("Content-type:text/html;charset=utf-8"); $link = mysqli_connect('localhost','root','','a'); mysqli_set_charset($link, "utf8"); if (!$link) { die("連線失敗:".mysqli_connect_error()); } ?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PHP+mysql開發的簡單投票系統</title> <style type="text/css"> /*全域性樣式*/ body { font-family: "宋體"; font-size: 12pt; color: #333333; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;background-color: #d4d4d4;} table { font-family: "宋體"; font-size: 9pt; line-height: 20px; color: #333333} /*全域性樣式結束*/ </style> <script language="javascript"> function selectAll() { node=window.document.frm.itm; for(i=0;i<node.length;i++) { node[i].checked=true;//全選 } } function cancelAll() { node=frm.itm; for(i=0;i<node.length;i++) { node[i].checked=false;//取消全部 } } function del() { node=frm.itm; id=""; for(i=0;i<node.length;i++) { if(node[i].checked) { if(id=="")//刪除 { id=node[i].value } else { id=id+","+node[i].value } } } if(id=="") { alert("您沒有選擇刪除項"); } else { location.href="?type=del&id=" rel="external nofollow" +id } } </script> </head> <body> <?php if(isset($_GET['tj']) == 'out'){ session_destroy();//刪除當前使用者對應的session檔案以及釋放session echo "<script language=javascript>alert('退出成功!');window.location='index.php'</script>"; } ?> <?php if(isset($_POST['Submit10'])){ if($_POST['pwd']=='admin'){ $_SESSION['pwd']=2; echo "<script language=javascript>alert('登陸成功!');window.location='admin.php'</script>"; }else{ echo "<script language=javascript>alert('登陸失敗,請檢查您的密碼!');window.location='admin.php'</script>"; } } ?> <?php if($_SESSION['pwd']<>2){ ?> <form action="" method="post"> <table width="365" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#C2C2C2"> <tr> <td height="30" align="right" bgcolor="#FFFFFF"><label>輸入密碼:</label></td> <td align="left" bgcolor="#FFFFFF"><input name="pwd" type="text" id="pwd" /></td> </tr> <tr> <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"><label> <input name="Submit10" type="submit" id="Submit10" value="登陸" /> </label> <label> <input type="reset" name="Submit5" value="重置" /> </label></td> </tr> <tr> <td height="30" colspan="2" align="center" bgcolor="#FFFFFF"> 軟體版本:<script type="text/javascript" src="http://www.04ie.com/net/phpvoto1_1.js"></script></td> </tr> </table> </form> <?php }else{ ?> <?php if(isset($_POST["Submit"])) { $title=$_POST["title"]; $sql="update vototitle set vototitle='$title'"; mysqli_query($link,$sql); ?> <script language="javascript"> alert("修改成功"); </script> <?php } if(isset($_POST["Submit2"])) { $newitem=$_POST["newitem"]; $sql="insert into voto (titleid,item,count) values (1,'$newitem',1)"; mysqli_query($link,$sql); } ?> <form id="frm" name="frm" method="post" action="" style="margin-bottom:3px;"> <table width="365" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#C2C2C2"> <tr> <td colspan="4" bgcolor="#FFFFFF"><label> <?php $sql="select * from vototitle"; $rs=mysqli_query($link,$sql); $rows=mysqli_fetch_assoc($rs); ?> <input name="title" type="text" id="title" size="35" value="<?php echo $rows["vototitle"]?>" /> </label></td> <td width="68" align="center" bgcolor="#FFFFFF"><label> <input type="submit" name="Submit" value="修改標題" /> </label></td> </tr> <tr> <th width="30" bgcolor="#FFFFFF">編號</th> <th width="45" bgcolor="#FFFFFF">專案</th> <th width="52" bgcolor="#FFFFFF">票數</th> <th width="50" align="center" bgcolor="#FFFFFF">修改</th> <th align="center" bgcolor="#FFFFFF">刪除</th> </tr> <?php $sql="select * from voto order by count desc"; $rs=mysqli_query($link,$sql); while($rows=mysqli_fetch_assoc($rs)) { ?> <tr> <td align="center" bgcolor="#FFFFFF"><input type="checkbox" name="itm" value="<?php echo $rows["id"]?>" /><?php echo $rows["id"]?></td> <td align="center" bgcolor="#FFFFFF"><?php echo $rows["item"]?></td> <td align="center" bgcolor="#FFFFFF"><?php echo $rows["count"]?></td> <td align="center" bgcolor="#FFFFFF"><input type="button" value="修改" onclick="location.href='?type=modify&id=<?php echo $rows["id"]?>'" /></td> <td align="center" bgcolor="#FFFFFF"><input type="button" value="刪除" onclick="location.href='?type=del&id=<?php echo $rows["id"]?>'" /></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"> <input type="button" value="選擇全部" onclick="selectAll()" /> <input type="button" value="取消全部" onclick="cancelAll()" /> <input type="button" value="刪除所選" onclick="del()" /> </td> </tr> <tr> <td colspan="3" bgcolor="#FFFFFF"><label> <input name="newitem" type="text" id="newitem" /> </label></td> <td colspan="2" bgcolor="#FFFFFF"><label> <input type="submit" name="Submit2" value="新增新項" /> </label> <a href="?tj=out" rel="external nofollow" >退出管理</a></td> </tr> </table> </form> <?php $type = isset($_GET["type"])?$_GET["type"]:""; if($type =="modify"){ $id=$_GET["id"]; if(isset($_POST["Submit3"])) { $item=$_POST["itm"]; $count=$_POST["count"]; $sql="update voto set item='$item',count=$count where id=$id"; mysqli_query($link,$sql); echo "<script language=javascript>alert('修改成功!');window.location='admin.php'</script>"; } $sql="select * from voto where id=$id"; $rs=mysqli_query($link,$sql); $rows=mysqli_fetch_assoc($rs); ?> <form id="form1" name="form1" method="post" action="" style="margin-top:2px;"> <table width="365" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#C2C2C2"> <tr> <th colspan="2" bgcolor="#FFFFFF">修改投票專案</th> </tr> <tr> <td align="center" bgcolor="#FFFFFF">名稱:</td> <td bgcolor="#FFFFFF"><label> <input name="itm" type="text" id="itm" value="<?php echo $rows["item"]?>" /> </label></td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">票數:</td> <td bgcolor="#FFFFFF"><label> <input name="count" type="text" id="count" value="<?php echo $rows["count"]?>" /> </label></td> </tr> <tr> <td colspan="2" align="center" bgcolor="#FFFFFF"><label> <input type="submit" name="Submit3" value="修改" /> <input type="reset" name="Submit" value="重置" /> </label></td> </tr> </table> </form> <?php } ?> <?php $type = isset($_GET["type"])?$_GET["type"]:""; if($type =="del"){ $id=$_GET["id"]; $sql="delete from voto where id in ($id)"; mysqli_query($link,$sql); echo "<script language=javascript>alert('刪除成功!');window.location='admin.php'</script>"; } ?> <?php } ?> </body> </html>
<?php ob_start(); session_start(); header("Content-type:text/html;charset=utf-8"); $link = mysqli_connect('localhost','root','','a'); mysqli_set_charset($link, "utf8"); if (!$link) { die("連線失敗:".mysqli_connect_error()); } ?> <!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>投票系統</title> <script type="text/javascript" src="//cdn.bootcss.com/jquery/1.12.4/jquery.js"></script> <style type="text/css"> /*全域性樣式*/ body { font-family: "宋體"; font-size: 12pt; color: #333333; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;background-color: #A6C7E1;} table { font-family: "宋體"; font-size: 9pt; line-height: 20px; color: #333333} a:link { font-size: 9pt; color: #333333; text-decoration: none} a:visited { font-size: 9pt; color: #333333; text-decoration: none} a:hover { font-size: 9pt; color: #E7005C; text-decoration: underline} a:active { font-size: 9pt; color: #333333; text-decoration: none} /*全域性樣式結束*/ </style> <script language="javascript"> function check() { node=frm.itm; flag=false; for(i=0;i<node.length;i++) { if(node[i].checked) { flag=true; } } if(!flag) { alert("您沒有選擇") return false; } return true; } </script> <?php if(isset($_POST["submit"])){ if($_POST){ $id = $_POST["selected_id"]; $sql = "update voto set count = count+1 where id=$id"; mysqli_query($link,$sql); } if($_SESSION["voto"]==session_id()) { ?> <script language="javascript"> alert("您已經投票了"); location.href="index.php" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ; </script> <?php exit(); } $id=$_POST["itm"]; $sql="update voto set count=count+1 where id=$id"; if(mysqli_query($link,$sql)) { $_SESSION["voto"]=session_id(); ?> <script language="javascript">alert("投票成功,點確定檢視結果");location.href="index.php?id=ck" rel="external nofollow" ;</script> <?php } else { ?> <script language="javascript">alert("投票失敗");location.href="index.php" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ;</script> <?php } } ?> </head> <body> <form name="frm" action="" method="post" onsubmit=return(check()) style="margin-bottom:5px;"> <table width="365" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#C2C2C2"> <tr> <th bgcolor="#FFFFCC"> <?php $sql="select * from vototitle"; $rs=mysqli_query($link,$sql); $row=mysqli_fetch_assoc($rs); echo $row["vototitle"]; ?> </th> </tr> <?php $sql="select * from voto"; $rs=mysqli_query($link,$sql); while($rows=mysqli_fetch_assoc($rs)) { ?> <tr> <td bgcolor="#FFFFFF"><input type="radio" name="itm" value="<?php echo $rows["id"]?>" /> <?php echo $rows["item"]?></td> </tr> <?php } ?> <tr> <td align="center" bgcolor="#FFFFFF"> <input type="submit" name="submit" value="投票"/> <input type="hidden" id="selected_id" name="selected_id" value=""> <input type="button" value="檢視結果" onClick="location.href='index.php?id=ck'"/> <script type="text/javascript"> $("[type='radio']").click(function(){ $("#selected_id").val($(this).val()); }); </script></td> </tr> </table> </form> <?php if(isset($_GET["id"])=="ck"){?> <?php $sql="select sum(count) as 'total' from voto"; $rs=mysqli_query($link,$sql); $rows=mysqli_fetch_assoc($rs); $sum=$rows["total"]; //得出總票數 $sql="select * from voto"; $rs=mysqli_query($link,$sql); ?> <table id="click" width="365" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#C2C2C2" > <tr> <th bgcolor="#FFFFFF">專案</th> <th bgcolor="#FFFFFF">票數</th> <th bgcolor="#FFFFFF">百分比</th> </tr> <?php while($rows=mysqli_fetch_assoc($rs)) { ?> <tr> <td bgcolor="#FFFFFF"><?php echo $rows["item"]?></td> <td bgcolor="#FFFFFF"><?php echo $rows["count"]?></td> <td bgcolor="#FFFFFF"> <?php $per=$rows["count"]/$sum; $per=number_format($per,4); ?> <img src="" height="4" width="<?php echo $per*100?>" /> <?php echo $per*100?>% </td> </tr> <?php } ?> </table> <div align="center"> <a href="index.php" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >隱藏結果</a> </div> <?php } ?> </body> </html>
到此這篇關於PHP實戰之投票系統的實現的文章就介紹到這了,更多相關PHP投票系統內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45