-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_data.php
117 lines (114 loc) · 2.41 KB
/
fetch_data.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
116
117
<?php
//fetch_data.php
$connect = new PDO("mysql:host=localhost;dbname=db_form", "root", "");
include_once('inc/config.php');
include ('inc/koneksi.php');
if(isset($_POST["action"]))
{
$query = "
SELECT * FROM tb_form WHERE id_form
";
if (!empty($_POST['fromDate']) && !empty($_POST['toDate'])) {
$fromDate = $_POST['fromDate'];
$toDate = $_POST['toDate'];
$query = "SELECT * FROM tb_form WHERE tanggal BETWEEN '{$fromDate}' AND '{$toDate}' ";
}
if(isset($_POST["pendidikan"]))
{
$pendidikan = implode("','", $_POST["pendidikan"]);
$query .= " AND pendidikan IN('".$pendidikan."')";
}
if(isset($_POST["pekerjaan"]))
{
$pekerjaan = implode("','", $_POST["pekerjaan"]);
$query .= "
AND pekerjaan IN('".$pekerjaan."')
";
}
if(isset($_POST["gender"]))
{
$gender = implode("','", $_POST["gender"]);
$query .= "
AND gender IN('".$gender."')
";
}
if(isset($_POST["soal1"]))
{
$soal1 = implode("','", $_POST["soal1"]);
$query .= "
AND soal1 IN('".$soal1."')
";
}
if(isset($_POST["soal2"]))
{
$soal2 = implode("','", $_POST["soal2"]);
$query .= "
AND soal2 IN('".$soal2."')
";
}
if(isset($_POST["soal3"]))
{
$soal3 = implode("','", $_POST["soal3"]);
$query .= "
AND soal3 IN('".$soal3."')
";
}
if(isset($_POST["soal4"]))
{
$soal4 = implode("','", $_POST["soal4"]);
$query .= "
AND soal4 IN('".$soal4."')
";
}
if(isset($_POST["soal5"]))
{
$soal5 = implode("','", $_POST["soal5"]);
$query .= "
AND soal5 IN('".$soal5."')
";
}
if(isset($_POST["soal6"]))
{
$soal6 = implode("','", $_POST["soal6"]);
$query .= "
AND soal6 IN('".$soal6."')
";
}
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$total_row = $statement->rowCount();
$result = mysqli_query($conn, $query);
$no=1;
$output = '';
if($total_row > 0)
{
if (mysqli_num_rows($result) > 0) {
foreach($result as $row)
{
$output .= '
<tr>
<td>'.$no++.'</td>
<td>'.$row["tanggal"].'</td>
<td>'.$row["gender"].'</td>
<td>'.$row["pendidikan"].'</td>
<td>'.$row["pekerjaan"].'</td>
<td>'.$row["soal1"].'</td>
<td>'.$row["soal2"].'</td>
<td>'.$row["soal3"].'</td>
<td>'.$row["soal4"].'</td>
<td>'.$row["soal5"].'</td>
<td>'.$row["soal6"].'</td>
</tr>
';
}
}
}
else
{
$output = '<tr>
<td colspan="12" align="center">No Data Found</td>
</tr>';
}
echo $output;
}