-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilterFunction.php
More file actions
127 lines (114 loc) · 4.31 KB
/
Copy pathFilterFunction.php
File metadata and controls
127 lines (114 loc) · 4.31 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
<?php
include("ini/classes.php");
//require_once(".\search\dbcontroller.php");
//$db_handle = new DBController();
$onderwerp = "";
$wat = "";
$why = "";
$how = "";
$niveau = "";
if(isset($_POST['Search'])
//er moet wel ergens op gezocht worden....
and !(empty($_POST["onderwerp"]) and empty($_POST["wat"]) and empty($_POST["why"]) and empty($_POST["how"]) and empty($_POST['niveau']))) {
$onderwerp = $_POST["onderwerp"];
$wat = $_POST["wat"];
$why = $_POST["why"];
$how = $_POST["how"];
if (! empty($_POST['niveau'])) {
$selectedOption="";
foreach ($_POST['niveau'] as $niveau) {
$selectedOption = $selectedOption . $niveau ;
if ( next( $_POST['niveau'] ) ) {
$selectedOption = $selectedOption . "|";
}
}
$niveau =$selectedOption;
} else {$niveau = "";}
$query = "SELECT * FROM sch_map.kenniskaart
WHERE onderwerp ~* '".$onderwerp."'
AND wat ~* '".$wat."'
AND why ~* '".$why."'
AND how ~* '".$how."'
AND niveau ~* '".$niveau."'
ORDER BY kenniskaart_id desc";
//echo $query;
// $result = $db_handle->runQuery($query);
$result=Connection::get()->connect()->query($query)->fetchAll(PDO::FETCH_ASSOC);
}
// ter voorbereiding van de opbouw van de combobox..
$comboquery = "SELECT lower(niveau) niveau FROM sch_map.kenniskaart group by niveau order by 1";
$comboresult=Connection::get()->connect()->query($comboquery)->fetchAll(PDO::FETCH_ASSOC);
if (! empty($comboresult)) {
foreach ($comboresult as $k => $v) {
echo '<option value="' . $comboresult[$k]['niveau'] . '">' . $comboresult[$k]['niveau'] . '</option>';
}
}
?>
<html>
<head>
<title>Zoeken</title>
<link href="style.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<h2>PHP CRUD with Search and Pagination</h2>
<div id="toys-grid">
<form name="frmSearch" method="post" action="filterfunction.php">
<div class="search-box">
<p>
<input type="text" id="mysearch" placeholder="onderwerp" name="search[onderwerp]" class="demoInputBox" value="<?php echo $onderwerp; ?>"/>
<input type="text" id="mysearch" placeholder="wat" name="search[wat]" class="demoInputBox" value="<?php echo $wat; ?>"/>
<input type="text" id="mysearch" placeholder="why" name="search[why]" class="demoInputBox" value="<?php echo $why; ?>"/>
<input type="text" id="mysearch" placeholder="how" name="search[how]" class="demoInputBox" value="<?php echo $how; ?>"/>
<select id="Place" name="search[niveau]" multiple="multiple" SIZE="5">
<?php
//echo display_sql_table($query,400);
?>
</select><br> <br>
<input type="submit" name="Search" id="Search" value="Search">
<input type="reset" class="btnSearch" value="Reset" onclick="window.location='filterfunction.php'">
<table cellpadding="10" cellspacing="1">
<thead>
<tr>
<th><strong>Onderwerp</strong></th>
<th><strong>Rol</strong></th>
<th><strong>Competentie</strong></th>
<th><strong>Wat</strong></th>
<th><strong>Why</strong></th>
<th><strong>How</strong></th>
<th><strong>Plaatje</strong></th>
<th><strong>Bronnen</strong></th>
<th><strong>Niveau</strong></th>
<th><strong>Studieduur</strong></th>
<th><strong>Rating</strong></th>
</tr>
</thead>
<tbody>
<?php
if (! empty($result)) {
foreach ($result as $k => $v) {
if(is_numeric($k)) {
?>
<tr>
<td><?php echo $result[$k]["onderwerp"]; ?></td>
<td><?php echo $result[$k]["rol"]; ?></td>
<td><?php echo $result[$k]["competentie"]; ?></td>
<td><?php echo $result[$k]["wat"]; ?></td>
<td><?php echo $result[$k]["why"]; ?></td>
<td><?php echo $result[$k]["how"]; ?></td>
<td><img src='<?php echo $result[$k]["plaatje"]; ?>' ></td>
<td><?php echo $result[$k]["bronnen"]; ?></td>
<td><?php echo $result[$k]["niveau"]; ?></td>
<td><?php echo $result[$k]["studieduur"]; ?></td>
<td><?php echo $result[$k]["rating"]; ?></td>
</tr>
<?php
}
}
}
?>
<tbody>
</table>
</form>
</div>
</body>
</html>