forked from cwerner6/databases-final-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
127 lines (97 loc) · 3.96 KB
/
search.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
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html>
<body>
<div style="height:900px; background-color: lightblue;" align="center">
<br><br><br><br>
<?php
require("../tableshow.php");
require("../dbconnect.php");
if(isset($_POST['search_album'])) {
$a_ID = $_POST['a_ID'];
$sql = "SELECT album ".
"WHERE album_id = '$a_ID'";
$retval = mysqli_query($conn, $sql);
if(!$retval) {
die('Could not find album data: ' . mysqli_error($conn));
}
echo "Successfully searched album data\n";
show_albums($conn);
mysqli_close($conn);
}
else if(isset($_POST['search_artist'])) {
$a_name = $_POST['a_ID'];
$sql = "SELECT artist ".
"WHERE artist_name = '$a_Name'";
$retval = mysqli_query($conn, $sql);
if(!$retval) {
die('Could not find artist data: ' . mysqli_error($conn));
}
echo "Successfully searched artist data\n";
show_albums($conn);
mysqli_close($conn);
}
else if(isset($_POST['search_genre'])) {
$g_ID = $_POST['g_ID'];
$sql = "SELECT artist ".
"WHERE genre_ID = '$g_ID'";
$retval = mysqli_query($conn, $sql);
if(!$retval) {
die('Could not find genre data: ' . mysqli_error($conn));
}
echo "Successfully searched genre data\n";
show_albums($conn);
mysqli_close($conn);
}
else {
?>
<p>Search:</p>
<form method="post" action="<?php $_PHP_SELF ?>">
<table width = "600" border = "0" cellspacing = "1" cellpadding = "2">
<tr>
<td width = "250">Search Album ID</td>
<td>
<input name ="a_ID" type ="text" id ="a_ID">
</td>
</tr>
<tr>
<td width = "250">Search Arist Name</td>
<td>
<input name ="a_Name" type ="text" id ="a_Name">
</td>
</tr>
<tr>
<td width = "250">Search Genre Name</td>
<td>
<input name ="g_ID" type ="text" id ="g_ID">
</td>
</tr>
<tr>
<td width = "250"> </td>
<td>
<input name ="search_album" type ="submit" id ="search_album" value ="Search Album">
</td>
</tr>
<tr>
<td width = "250"> </td>
<td>
<input name ="search_artist" type ="submit" id ="search_artist" value ="Search Artist">
</td>
</tr>
<tr>
<td width = "250"> </td>
<td>
<input name ="search_genre" type ="submit" id ="search_genre" value ="Search Genre">
</td>
</tr>
</table>
</form>
<?php
}
?>
<br><br><br><br>
<hr width="50">
<a href="index.php" style="color:red;font-weight:bold;">Home</a>
<hr width="50">
</div>
</body>
</html>