-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathno6_QuickCountApps.php
More file actions
78 lines (71 loc) · 1.51 KB
/
no6_QuickCountApps.php
File metadata and controls
78 lines (71 loc) · 1.51 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
<!DOCTYPE html>
<html>
<head>
<title>Aplikasi Menampilkan Data Quick Count</title>
<style type="text/css">
body{
background-color:rgba(0,0,0,0.1);
}
tr{
.tmbh{
text-align:center;
}
}
input[type='submit']{
background-color:red;
color:white;
font-weight:bolder;
font-size:20px;
}
td{
background-color:rgba(0,0,0,0.3);
color:black;
font-weight:bold;
font-size:17px;
}
h1{
text-align:center;
}
</style>
</head>
<body>
<?php
$kon=mysqli_connect("localhost","root","","count");
function masukkan($queryy){
global $kon;
$result=mysqli_query($kon,$queryy);
$wadah=[];
while($baris=mysqli_fetch_assoc($result)){
$wadah[]=$baris;
}
return $wadah;
}
$query=masukkan("SELECT * FROM tb_caleg");
$n=0;
?>
<h1>DATA PEROLEHAN SUARA CALEG</h1>
<form method="POST">
<table border="1" cellspacing="2" cellpadding="2" align="center">
<?php foreach($query as $content): ?>
<tr>
<td><?= $content['name']; ?></td>
<td rowspan="2"><input type="Submit" name="tambah" value="Tambah"></td>
</tr>
<tr>
<td><?= "perolehan suara :".$content['earned_vote']; ?></td>
</tr>
<?php
if(isset($_POST['tambah'])){
$id=$content['id'];
$name=$content['name'];
$id_partai=$content['id_partai'];
$earned_vote=$content['earned_vote'];
$koneksi=mysqli_connect('localhost','root','','count');
mysqli_query($koneksi,"UPDATE tb_caleg SET name='$name',id_partai='$id_partai',earned_vote+=$earned_vote+1) WHERE id=$id");
}
?>
<?php endforeach ?>
</table>
</form>
</body>
</html>