-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstays_in_select.php
More file actions
54 lines (42 loc) · 1.3 KB
/
stays_in_select.php
File metadata and controls
54 lines (42 loc) · 1.3 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
<?php
include "config.php";
if (!empty($_GET["pid"])){
$pid = $_GET["pid"];
$sql_comment = "SELECT * FROM stays_in WHERE p_id = '".$pid."' ";
if(!empty($_GET["rid"])) {
$rid = $_GET["rid"];
$sql_comment .= " AND room_id = '".$rid."' ";
}
if(!empty($_GET["dod"])) {
$dod = $_GET["dod"];
$sql_comment .= " AND date_discharge = '".$dod."' ";
}
$myresult = mysqli_query($db,$sql_comment);
while($rows = mysqli_fetch_assoc($myresult)){
echo $rows["p_id"] . " - " . $rows["room_id"] . " - " . $rows["date_discharge"] . "<br>";
}
}
else {
$sql_comment = "SELECT * FROM stays_in ";
$hasWhere = false;
if(!empty($_GET["rid"])) {
$rid = $_GET["rid"];
$sql_comment .= " WHERE room_id = '".$rid."' ";
$hasWhere = true;
}
if(!empty($_GET["dod"])) {
$dod = $_GET["dod"];
if($hasWhere) {
$sql_comment .= " AND date_discharge = '".$dod."' ";
}
else {
$sql_comment .= " WHERE date_discharge = '".$dod."' ";
$hasWhere = true;
}
}
$myresult = mysqli_query($db,$sql_comment);
while($rows = mysqli_fetch_assoc($myresult)){
echo $rows["p_id"] . " - " . $rows["room_id"] . " - " . $rows["date_discharge"] . "<br>";
}
}
?>