forked from edlcn/cs306db
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecord_select.php
More file actions
53 lines (41 loc) · 1.22 KB
/
record_select.php
File metadata and controls
53 lines (41 loc) · 1.22 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
<?php
include "config.php";
if (!empty($_GET["rid"])){
$rid = $_GET["rid"];
$sql_comment = "SELECT * FROM record WHERE rec_id = '".$rid."' ";
if (!empty($_GET["pid"])){
$pid = $_GET["pid"];
$sql_comment .= " AND p_id = '".$pid."' ";
}
if (!empty($_GET["date"])){
$date = $_GET["date"];
$sql_comment .= " AND date = '".$date."' ";
}
$myresult = mysqli_query($db,$sql_comment);
while($rows = mysqli_fetch_assoc($myresult)){
echo $rows["rec_id"] . " - " . $rows["p_id"] . " - " . $rows["date"] . "<br>";
}
}
else {
$sql_comment = "SELECT * FROM record";
$hasWhere = false;
if (!empty($_GET["pid"])){
$pid = $_GET["pid"];
$sql_comment .= " WHERE p_id = '".$pid."' ";
$hasWhere = true;
}
if (!empty($_GET["date"])){
$date = $_GET["date"];
if($hasWhere) {
$sql_comment .= " AND date = '".$date."' ";
}
else {
$sql_comment .= " WHERE date = '".$date."' ";
}
}
$myresult = mysqli_query($db,$sql_comment);
while($rows = mysqli_fetch_assoc($myresult)){
echo $rows["rec_id"] . " - " . $rows["p_id"] . " - " . $rows["date"] . "<br>";
}
}
?>