首页 > 代码库 > 例子 投票系统
例子 投票系统
1.建立数据库
表1:DiaoYanTiMu
表2:DiaoYanXuanXiang
2.页面
页面1:投票首页
<!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"> #fanhui{ display:none} </style> </head> <body> <form action="tpchuli.php" method="post"> <?php $db = new MySQLi("localhost","root","123","mydb"); $sql = "select * from diaoyantimu"; $result = $db->query($sql); $attr = $result->fetch_all(); foreach($attr as $v) { echo "<div>{$v[1]}</div>"; $sxx = "select * from diaoyanxuanxiang where timudaihao=‘{$v[0]}‘"; $rxx = $db->query($sxx); $axx = $rxx->fetch_all(); $bs = 0; if(!empty($_GET["a"])) { $bs = $_GET["a"]; } $s = $bs==1?"none":"block"; echo "<div id=‘toupiao‘ style=‘display:{$s}‘>"; foreach($axx as $v1) { echo "<div><input type=‘checkbox‘ name=‘tp[]‘ value=http://www.mamicode.com/‘{$v1[0]}‘ />{$v1[1]}
页面2:处理页面
<?php $attr = $_POST["tp"]; $str = implode("‘,‘",$attr); $sql = "update diaoyanxuanxiang set numbers = numbers+1 where ids in(‘{$str}‘)"; $db = new MySQLi("localhost","root","123","mydb"); $db->query($sql); header("location:toupiao.php?a=1");
例子 投票系统
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。