-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
155 lines (140 loc) · 4.73 KB
/
example.php
File metadata and controls
155 lines (140 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php include 'db.php';?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bluemix云端数据库服务使用示例———PHP投票程序 - 无知人生,记录点滴</title>
<style>
body {
margin:0; padding:0;
}
a{
text-decoration:none;
color:black;
}
div.div_id {
float:left;
clear:left;
width:60px;
height:27px;
border-bottom:solid 1px #808080;
text-align:center;
line-height:27px;
}
div.div_item {
float:left;
clear:none;
width:260px;
height:27px;
border-bottom:solid 1px #808080;
text-align:left;
line-height:27px;
}
div.div_radio {
float:left;
clear:none;
width:60px;
height:27px;
border-bottom:solid 1px #808080;
text-align:left;
line-height:27px;
display:none;
}
div.div_num {
float:left;
clear:right;
width:260px;
height:27px;
border-bottom:solid 1px #808080;
text-align:left;
line-height:27px;
display:none;
}
</style>
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<SCRIPT language=javascript>
$(document).ready(function(){
//判断是否已经投过票了,如果投过票了,就不再显示投票按钮,而是显示投票结果;
if (document.cookie == "" || document.cookie == "abc="){
var ck = document.cookie;
alert("cookie == " + ck +" null or abc=");
$("#button1").show();
$("div.div_radio").show();
}else{
alert("cookie == " + ck +" not null or abc= \\\\\ else");
$("div.div_num").show();
}
});
//通过AJAX调用后台保存投票信息
function execVote(){
var id = $('input[name="radio1"]:checked').val();
if (id == "" || id == undefined){
alert("请选择投票项!");
return;
}
$("#button1").hide();
$.ajax({
type: "POST",
url: "vote.php",
dataType:"html",
data: {"id":id},
success: function(data){
$("#div_num_" + id).text(parseInt($("#div_num_" + id).text()) + 1);
$("div.div_radio").hide();
$("div.div_num").show();
document.cookie = "abc=123";
console.log(data);
},
error: function(data){
console.log(data);
alert( "投票失败: " + data.responseText );
}
});
}
</SCRIPT>
</head>
<body>
<div>
<a href="http://blog.csdn.net/testcs_dn" target="_blank" title="无知人生,记录点滴 不积硅步,无以至千里;不积小流,无以成江海……">
<img src="" border=0 />
</a>
</div>
<div style="width:640px; height:40px; border-bottom:solid 1px #808080;text-align:center;">
<a href="http://blog.csdn.net/testcs_dn/article/details/49965993"><h3>你曾后悔进入 IT 行业吗?</h3></a>
</div>
<div id="Wrapper" style="padding: 0px; margin: 0px; min-height:300px; text-align: center; background-color: rgb(255, 255, 255);">
<form>
<?php
$result = $mysqli->query("SELECT * FROM vote_item");
$rowIdx = 0;
while(!!$row = $result->fetch_object())
{
$rowIdx += 1;
echo "<div class=\"div_id\">" . $rowIdx . "</div>";
echo "<div class=\"div_item\">" . $row->vote_item . "</div>";
echo "<div class=\"div_radio\"><input type=\"radio\" id=\"radio1\" name=\"radio1\" value=\"" . $row->id . "\" /></div>";
echo "<div class=\"div_num\" id=\"div_num_" . $row->id . "\">" . $row->vote_num . "</div>";
}
$mysqli->close();
?>
</form>
<div style="width:640px; height:40px; border-bottom:solid 1px #808080;text-align:center; float:left; clear:both; margin-top:15px;">
<input type="button" id="button1" name="button1" value="投票" onclick="execVote()" style="display:none" />
</div>
</div>
<hr />
<div style="margin:auto; text-align:center; line-height:28px;">
云服务器:<a href="https://console.ng.bluemix.net/home/" target="_blank" title="IBM Bluemix 数字创新平台" style="">
IBM Bluemix 数字创新平台
</a><br />
服务提供:<a href="https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/language-translation/api/v2/#introduction" target="_blank" title="IBM Watson Developer Cloud" style="">
IBM Watson Language Translator
</a>
</div>
<div style="margin:auto; text-align:center; line-height:28px;">
<a href="http://blog.csdn.net/testcs_dn" target="_blank" title="无知人生,记录点滴 不积硅步,无以至千里;不积小流,无以成江海……" style="">
Powered by:amfang<br />
无知人生,记录点滴 不积硅步,无以至千里;不积小流,无以成江海……
</a>
</div>
</body>
</html>