-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtampil_201651085.php
115 lines (110 loc) · 2.26 KB
/
tampil_201651085.php
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
<?php include "_header.php"; ?>
<table class="data" border="1" style="border-collapse: collapse; margin-bottom: 5px;">
<tr>
<th>No.</th>
<th>Tahun Akademik</th>
<th>Jumlah PMB</th>
<th>X</th>
<th>Y</th>
<th>XX</th>
<th>XY</th>
</tr>
<?php
$sql = mysqli_query($con, "SELECT * FROM pmb_201651085") or die (mysqli_error($con));
if (mysqli_num_rows($sql) > 0) {
$x = 0;
$jumlah_x = 0;
$jumlah_y = 0;
$jumlah_xx = 0;
$jumlah_xy = 0;
while ($data = mysqli_fetch_array($sql)) {
$jumlah_x += $x;
$jumlah_y += $data['jumlah_pmb'];
$jumlah_xx += ($x * $x);
$jumlah_xy += ($x * $data['jumlah_pmb']);
?>
<tr>
<td><?=$x+1;?>.</td>
<td><?=$data['tahun_akademik'];?></td>
<td align="center"><?=$data['jumlah_pmb'];?></td>
<td align="center"><?=$x;?></td>
<td align="center"><?=$data['jumlah_pmb'];?></td>
<td align="center"><?=$x * $x;?></td>
<td align="center"><?=$x * $data['jumlah_pmb'];?></td>
</tr>
<?php
$x++;
}
?>
<tr>
<td colspan="2">Jumlah</td>
<td></td>
<td><?=$jumlah_x;?></td>
<td><?=$jumlah_y;?></td>
<td><?=$jumlah_xx;?></td>
<td><?=$jumlah_xy;?></td>
</tr>
<tr>
<td colspan="2">Rata2</td>
<td></td>
<td>
<?php
$rata2_x = $jumlah_x / $x;
echo $rata2_x;
?>
</td>
<td>
<?php
$rata2_y = $jumlah_y / $x;
echo $rata2_y;
?>
</td>
<td colspan="2"></td>
</tr>
<tr>
<td colspan="2">B1</td>
<td colspan="5">
<?php
$b1 = ($jumlah_xy - (($jumlah_x * $jumlah_y) / $x)) / ($jumlah_xx - ($jumlah_x * $jumlah_x) / $x);
echo $b1;
?>
</td>
</tr>
<tr>
<td colspan="2">B0</td>
<td colspan="5">
<?php
$b0 = $rata2_y - $b1 * $rata2_x;
echo $b0;
?>
</td>
</tr>
<?php
}
?>
</table>
<div>
Rumus Regresi Linear :<br>
<?php
$y = $b0." + ".$b1." x";
echo $y;
?>
</div>
<?php
if(isset($_POST['prediksi'])) {
$tahun = $_POST['tahun'];
$thn = ($x - 1) + $tahun;
$prediksi = $b0 + ($b1 * $thn);
?>
<div>
Prediksi PMB untuk <?=$tahun;?> tahun berikutnya adalah <?=$prediksi;?>
</div>
<?php
}
?>
<div>
<a href="./">
<button>Halaman Utama</button>
</a>
</div>
<?php include "_footer.php"; ?>