導航:首頁 > 編程語言 > php手機投票

php手機投票

發布時間:2023-06-11 06:31:34

A. 在用php做一個投票系統,當用戶投票後,希望能實時的看到投票結果的變化,請問怎麼實現

實時看到投票結果,也就是web頁面局部刷新,這種效果僅依靠PHP是做不出來的,因為PHP是服務端腳本,通常是使用ajax技術來實現。

B. 用php製作一個網頁來實現簡易網上投票系統

<?php
header("Content-type:text/html;charset=utf-8");
$link=mysql_connect('localhost','root','')ordie('Couldnotconnecttomysqlserver');
mysql_select_db('tpxt',$link)ordie('Couldnotselectdatabase');
if(isset($_POST['submit'])){
$sql="SELECT`id`FROM`table`WHERE`uid`=".$_POST['uid'];
$result=mysql_query($sql);
if($result&&mysql_num_rows($result)){
$sql="UPDATE`table`SET`vote`=`vote`+1WHERE`uid`=".$_POST['uid'];
mysql_query($sql);
}else{
$sql="INSERTINTO`table`(uid,vote)VALUES('".$_POST['uid']."','1')";
mysql_query($sql);
}
echo"<script>alert('Ok投票成功!');</script>";
echo"<script>window.location.reload();</script>";
exit();
}else{
$sql="SELECT`vote`FROM`table`WHERE`uid`=3";
$result=mysql_query($sql);
if($result&&mysql_num_rows($result)){
$t3=mysql_fetch_assoc($result);
}else{
$t3['vote']=0;
}
$sql="SELECT`vote`FROM`table`WHERE`uid`=4";
$result=mysql_query($sql);
if($result&&mysql_num_rows($result)){
$t4=mysql_fetch_assoc($result);
}else{
$t4['vote']=0;
}
$sql="SELECT`vote`FROM`table`WHERE`uid`=5";
$result=mysql_query($sql);
if($result&&mysql_num_rows($result)){
$t5=mysql_fetch_assoc($result);
}else{
$t5['vote']=0;
}
$sql="SELECT`vote`FROM`table`WHERE`uid`=6";
$result=mysql_query($sql);
if($result&&mysql_num_rows($result)){
$t6=mysql_fetch_assoc($result);
}else{
$t6['vote']=0;
}
$sql="SELECT`vote`FROM`table`WHERE`uid`=7";
$result=mysql_query($sql);
if($result&&mysql_num_rows($result)){
$t7=mysql_fetch_assoc($result);
}else{
$t7['vote']=0;
}
$count=$t3['vote']+$t4['vote']+$t5['vote']+$t6['vote']+$t7['vote'];
$t3_b=$t3['vote']/$count;
$t4_b=$t4['vote']/$count;
$t5_b=$t5['vote']/$count;
$t6_b=$t6['vote']/$count;
$t7_b=$t7['vote']/$count;
}
?>

閱讀全文

與php手機投票相關的資料

熱點內容
程序員放棄後會怎樣 瀏覽:186
河北模具編程 瀏覽:189
adb查找命令 瀏覽:323
安卓手機視頻文件夾怎麼打開 瀏覽:313
平板加密手機後怎麼關閉 瀏覽:572
流媒體伺服器應該注意什麼 瀏覽:538
d8命令編譯 瀏覽:967
壓縮包解壓需要多少空間 瀏覽:148
如何查找app屬性 瀏覽:389
android人臉識別技術 瀏覽:323
pc104編程 瀏覽:336
二維碼反編譯破解推廣 瀏覽:684
修改伺服器的mac地址 瀏覽:529
好玩的編程軟體 瀏覽:901
編程語言創始人有錢嗎 瀏覽:808
短視頻app怎麼獲客 瀏覽:16
查看雲伺服器的應用 瀏覽:438
javadump工具 瀏覽:566
程序員16g 瀏覽:448
程序員沒有辦法成為top怎麼辦 瀏覽:221