国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

php+mysql+xml實(shí)現(xiàn)的問卷調(diào)查(代碼)

2020-03-22 17:12:57
字體:
供稿:網(wǎng)友
本篇文章給大家?guī)淼膬?nèi)容是關(guān)于php+mysql+xml實(shí)現(xiàn)的問卷調(diào)查(代碼),有一定的參考價(jià)值,有需要的朋友可以參考一下,希望對(duì)你有所幫助。

本人根據(jù)php典型模塊與項(xiàng)目實(shí)戰(zhàn)大全此書所完成的一個(gè)調(diào)查問卷,同時(shí)管理員可以進(jìn)行修改調(diào)查內(nèi)容

同時(shí)用到了一個(gè)css文件,借鑒于

http://www.wufangbo.com/p-css-vote/

需要5個(gè)php文件:admin.php、update.php、view.php、result.php、vote.php、

首先在WWW下新建一個(gè)文件夾 此處為名為 diaocha 本人的端口號(hào)為8080

數(shù)據(jù)庫如下:庫的名字為 cms_vote 表的名字為:vote


其中Votenote內(nèi)部的內(nèi)容為:

 movies  movie  title 您想去哪個(gè)城市: /title  id 1 /id  count 350 /count  content 廣東 /content  /movie  movie  title 您想去哪個(gè)城市: /title  id 2 /id  count 47 /count  content 湖南 /content  /movie  movie  title 您想去哪個(gè)城市: /title  id 3 /id  count 118 /count  content 上海 /content  /movie  movie  title 您想去哪個(gè)城市: /title  id 4 /id  count 122 /count  content 北京 /content  /movie  movie  title 您想去哪個(gè)城市: /title  id 5 /id  count 80 /count  content 湖北 /content  /movie  /movies 

1、admin.php

 ?php$con = mysql_connect( localhost , root , root )or die( could not connect database //此處根據(jù)自己的數(shù)據(jù)庫的名字,密碼進(jìn)行修改mysql_query( set names utf8 mysql_select_db( cms_vote )or die( could not select database $aid = $_GET[ aid if(!empty($aid)){$sql= SELECT *FROM vote //WHERE aid= .$aid. $result = mysql_query($sql,$con);$row = mysql_fetch_array($result);else{echo script alert(/ 調(diào)查異常/ /script exit;? 
 html  head  table width= 98% border=0 align= center cellpadding= 3 cellpadding= 1  td height= 28 b 調(diào)查管理 /b /td  /tr  tr height= 200 valign= top  form name= form1 method= post action= update.php  input type= hidden name = aid value= ?php echo $aid?  table width= 100% border= 0 cellpadding= 4 cellspacing= 4  td width= 15% align= center 調(diào)查項(xiàng)目: /td  td width= 85%  input name= votename type= text id= votename value= ?php echo $row[ Votename ?  /td  /tr  td align= center 調(diào)查總?cè)藬?shù): /td  input name= totalcount type= text id= totalcount value= ?php echo $row[ Totalcount ?  /td  /tr  td align= center 開始時(shí)間: /td  input name= starttime type= text id= starttime value= ?php echo $row[ Starttime ?  /td  /tr  td align= center 結(jié)束時(shí)間: /td  input name= endtime type= text id= endtime value= ?php echo $row[ Endtime ?  /td  /tr  td align= center 投票項(xiàng): /td  textarea name= votenote rows= 8 id = votenote >


2、update.php

 ?php$con = mysql_connect( localhost , root , root )or die( could not connect database //此處根據(jù)自己的數(shù)據(jù)庫的名字,密碼進(jìn)行修改mysql_query( set names utf8 mysql_select_db( cms_vote )or die( could not select database $aid = $_POST[ aid $votename=$_POST[ votename $starttime=$_POST[ starttime $endtime=$_POST[ endtime $votenote=$_POST[ votenote $totalcount=$_POST[ totalcount if(!empty($aid))$sql = UPDATE vote SET Votename= .$votename. , Starttime= .$starttime. , Endtime= .$endtime. , Totalcount= .$totalcount. , Votenote= .$votenote. WHERE aid= .$aid. order by aid desc limit 1; $result = mysql_query($sql);if(!empty($result)){echo script alert(/ 數(shù)據(jù)保存成功/ /script echo 您的調(diào)查問卷已生效! echo script alert(/ 數(shù)據(jù)保存失敗/ /script exit();else{echo script alert(/ 調(diào)查異常/ /script exit();? 

驗(yàn)證是否成功:http://localhost:8080/diaocha/admin.php?aid=1

(注意需要加上?aod=1)格式為英文格式

按下保存調(diào)查數(shù)據(jù)按鍵的時(shí)候:會(huì)出現(xiàn)

會(huì)出現(xiàn)您的調(diào)查問卷已生效

3、view.php

 ?php$voteitem = $_POST[ voteitem $con = mysql_connect( localhost , root , root )or die( could not connect database //密碼用戶名按照自己的修改mysql_query( set names utf8 mysql_select_db( cms_vote )or die( could not select database $sql= SELECT *FROM vote $result = mysql_query($sql,$con);$arr = mysql_fetch_array($result);$xmlstr = ?xml version=/ 1.0/ encoding=/ utf-8/ ? $xmlstr.=$arr[ Votenote $xml = simplexml_load_string($xmlstr);$b[]=Array();$a[]=Array();for($i=0;$i $i++){$b[$i]=$xml- movie[$i]- count;$a[$i]=$xml- movie[$i]- count+1;for($i=0;$i $i++){$b[$i]=$a[$i];$xmlstra[$i]= movies  movie  title . $xml- movie[0]- title . /title  id 1 /id  count .$b[0]. /count  content . $xml- movie[0]- content . /content  /movie  movie  title . $xml- movie[0]- title . /title  id 2 /id  count .$b[1]. /count  content . $xml- movie[1]- content . /content  /movie  movie  title . $xml- movie[0]- title . /title  id 3 /id  count .$b[2]. /count  content . $xml- movie[2]- content . /content  /movie  movie  title . $xml- movie[0]- title . /title  id 4 /id  count .$b[3]. /count  content . $xml- movie[3]- content . /content  /movie  movie  title . $xml- movie[0]- title . /title  id 4 /id  count .$b[4]. /count  content . $xml- movie[4]- content . /content  /movie  /movies if($voteitem!=null){$sql = UPDATE vote SET Totalcount=Totalcount+1,Votenote= .$xmlstra[$voteitem]. order by aid desc limit 1 $result = mysql_query($sql);$url = result.php?aid=1 switch($voteitem){case 0:if(!empty($result)){echo script alert( 投票1成功! location.href= .$url. /script exit();break;case 1:if(!empty($result)){echo script alert( 投票2成功! location.href= .$url. /script exit();break;case 2:if(!empty($result)){echo script alert( 投票3成功! location.href= .$url. /script exit();break;case 3:if(!empty($result)){echo script alert( 投票4成功! location.href= .$url. /script exit();break;case 4:if(!empty($result)){echo script alert( 投票5成功! location.href= .$url. /script exit();break;else{echo script window.close(); /script ? 

會(huì)出現(xiàn)以下結(jié)果

4、vote.php

 ?php$voteitem = $_POST[ voteitem $con = mysql_connect( localhost , root , root )or die( could not connect database mysql_query( set names utf8 mysql_select_db( cms_vote )or die( could not select database $sql= SELECT *FROM vote $result = mysql_query($sql,$con);$arr = mysql_fetch_array($result);$xmlstr = ?xml version=/ 1.0/ encoding=/ utf-8/ ? $xmlstr.=$arr[ Votenote $xml = simplexml_load_string($xmlstr);$b[]=Array();$a[]=Array();for($i=0;$i $i++){$b[$i]=$xml- movie[$i]- count;$a[$i]=$xml- movie[$i]- count+1;for($i=0;$i $i++){$b[$i]=$a[$i];$xmlstra[$i]= movies  movie  title . $xml- movie[0]- title . /title  id 1 /id  count .$b[0]. /count  content . $xml- movie[0]- content . /content  /movie  movie  title . $xml- movie[0]- title . /title  id 2 /id  count .$b[1]. /count  content . $xml- movie[1]- content . /content  /movie  movie  title . $xml- movie[0]- title . /title  id 3 /id  count .$b[2]. /count  content . $xml- movie[2]- content . /content  /movie  movie  title . $xml- movie[0]- title . /title  id 4 /id  count .$b[3]. /count  content . $xml- movie[3]- content . /content  /movie  movie  title . $xml- movie[0]- title . /title  id 4 /id  count .$b[4]. /count  content . $xml- movie[4]- content . /content  /movie  /movies if($voteitem!=null){$sql = UPDATE vote SET Totalcount=Totalcount+1,Votenote= .$xmlstra[$voteitem]. order by aid desc limit 1 $result = mysql_query($sql);$url = result.php?aid=1 switch($voteitem){case 0:if(!empty($result)){echo script alert( 投票1成功! location.href= .$url. /script exit();break;case 1:if(!empty($result)){echo script alert( 投票2成功! location.href= .$url. /script exit();break;case 2:if(!empty($result)){echo script alert( 投票3成功! location.href= .$url. /script exit();break;case 3:if(!empty($result)){echo script alert( 投票4成功! location.href= .$url. /script exit();break;case 4:if(!empty($result)){echo script alert( 投票5成功! location.href= .$url. /script exit();break;else{echo script window.close(); /script ? 

5、result.php

 ?php$con = mysql_connect( localhost , root , root )or die( could not connect database mysql_query( set names utf8 mysql_select_db( cms_vote )or die( could not select database $aid = $_GET[ aid if(!empty($aid)){$sql= SELECT *FROM vote WHERE aid= .$aid. $result = mysql_query($sql,$con);$arr = mysql_fetch_array($result);$xmlstr = ?xml version=/ 1.0/ encoding=/ utf-8/ ? $xmlstr.=$arr[ Votenote $xml = simplexml_load_string($xmlstr);$n0=$xml- movie[0]- count/$arr[ Totalcount $n1=$xml- movie[1]- count/$arr[ Totalcount $n2=$xml- movie[2]- count/$arr[ Totalcount $n3=$xml- movie[3]- count/$arr[ Totalcount $n4=$xml- movie[4]- count/$arr[ Totalcount /*elseecho script alert(/ 調(diào)查異常/ /script exit;? 
 html  head  style #graphbox{border:1px solid #e7e7e7;padding:10px;width:545px;background-color:#f8f8f8;margin:5px 0;//這是最大的一個(gè)div.itemname{width:70px;font-weight:700;font-size:14px;line-height:18px;height:18px;padding:2px;text-align:right;margin-right:atuo;.percent{width:150px;float:right;font-size:13px;line-height:18px;height:18px;padding:2px;color:#555;text-align:left;margin-right:3px;.graph{position:relative;background-color:#F0EFEF;border:1px solid #cccccc;font-size:13px;width:300px;font-weight:700;float:right;margin-right:3px;.color1, .color2, .color3, .color4, .color5{position:relative;text-align:left;color:#ffffff;height:18px;display:block;.graph .color1{background-color:#afb4db;}.graph .color2{background-color:#84bf96;}.graph .color3{background-color:#ea66a6;}.graph .color4{background-color:#50b7c1;}.graph .color5{background-color:#ffd400;}.font1{color:#669999;}.font2{color:#6699FF;}.font3{color:#FF9900;}.font4{color:#FF3333;} /style  body  h3 ?php echo $arr[ Votename ? /h3  td 調(diào)查結(jié)果 /td  div  td 調(diào)查開始時(shí)間: ?php echo $arr[ Starttime ? 調(diào)查結(jié)束時(shí)間: ?php echo $arr[ Endtime ? 調(diào)查總?cè)藬?shù): ?php echo $arr[ Totalcount ? /td /td  div  div id= graphbox  div >

以上就是php+mysql+xml實(shí)現(xiàn)的問卷調(diào)查(代碼)的詳細(xì)內(nèi)容,PHP教程

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請(qǐng)第一時(shí)間聯(lián)系我們修改或刪除,多謝。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 宜城市| 吉首市| 涞源县| 天柱县| 钟祥市| 湘潭县| 新昌县| 尼勒克县| 得荣县| 宜兴市| 绥江县| 阿瓦提县| 宁夏| 蕉岭县| 中山市| 离岛区| 宁陕县| 锡林郭勒盟| 五峰| 蒙阴县| 青岛市| 龙门县| 芜湖市| 宜城市| 咸丰县| 诏安县| 天水市| 兴化市| 文昌市| 长乐市| 昭通市| 延寿县| 修武县| 惠来县| 博湖县| 阿克苏市| 闽清县| 庄河市| 涪陵区| 肃北| 黄冈市|