-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
157 lines (122 loc) · 4.32 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
require_once('frame_header.php');
verifyUserSession();
$userid = $_SESSION["loginUsername"];
if(isset($_GET['keyword']) && make_safe($_GET['keyword']) != ""){
$keyword = make_safe($_GET['keyword']);
echo "<input type='hidden' class='keyword' value='$keyword'>";
}
else{
header("Location: foryou.php");
}
echo "<input type='hidden' class='userid' value='$userid'>";
//below are SQL queries
$query_song="SELECT t.trackname,a.artistitle,t.trackid,a.artistid
FROM artist a LEFT JOIN track t ON a.artistid=t.artistid
WHERE t.trackname LIKE '%$keyword%' OR a.artistitle LIKE '%$keyword%';";
$query_album="SELECT a.albumid, a.albumname, a.albumreleasedate
FROM album a
WHERE a.albumname LIKE '%$keyword%';";
$query_playlist="SELECT p.pid, p.ptitle, p.powner
FROM playlist p
WHERE p.ptitle LIKE '%$keyword%' AND (p.public!=0 OR p.powner='$userid');";
$query_user="SELECT u.username, u.uname, u.city
FROM user u
WHERE username LIKE '%$keyword%';";
?>
<div class="container-fluid">
<div class="row">
<div class="col-md">
<h3 class="text-danger">TRACK</h3>
<?php
$result=mysqli_query($conn,$query_song);
if(mysqli_num_rows($result)>0){
while ($row=mysqli_fetch_assoc($result)) {
// find artistid from trackid
$trackid=$row["trackid"];
$trackname=$row["trackname"];
$artistid=$row["artistid"];
$artistitle=$row["artistitle"];
echo "<div class='row listitem'>
<div class='col-md-7'>
<input type='hidden' class='td trackId' value='$trackid'>
<span class='trackName t'>$trackname</span>
</div>
<div class='col-md-5'>
<a href='artist.php?artistid=$artistid'>$artistitle</a>
<input type='hidden' class='ai' value='$artistid'>
<input type='hidden' class='trackId' value='$trackid'>
<img class='optionsButton' src='assets/images/icons/more.png' style='float:right' onclick='showOptionMenu(this)'>
</div>
</div><hr class='bg-danger'>";
}
}
?>
</div>
<div class="col-md">
<h3 class="text-primary">ALBUM</h3>
<?php
$result=mysqli_query($conn,$query_album);
if(mysqli_num_rows($result)>0){
while ($row=mysqli_fetch_assoc($result)) {
// find artistid from trackid
$albumid=$row["albumid"];
$albumname=$row["albumname"];
$albumreleasedate=$row["albumreleasedate"];
echo "<div class='row listitem'>
<div class='col-md-8'>
<a href='album.php?albumid=$albumid'><span class='trackName'>$albumname</span></a>
</div>
<div class='col-md-4'>
<a href=''>$albumreleasedate</a>
</div>
</div><hr class='bg-primary'>";
}
}
?>
</div>
<div class="col-md">
<h3 class="text-warning">PLAYLIST</h3>
<?php
$result=mysqli_query($conn,$query_playlist);
if(mysqli_num_rows($result)>0){
while ($row=mysqli_fetch_assoc($result)) {
// find artistid from trackid
$pid=$row["pid"];
$ptitle=$row["ptitle"];
$powner=$row["powner"];
echo "<div class='row listitem'>
<div class='col-md-8'>
<a href='playlist.php?pid=$pid'><span class='trackName'>$ptitle</span></a>
</div>
<div class='col-md-4'>
<a href='user.php?username=$powner'>$powner</a>
</div>
</div><hr class='bg-warning'>";
}
}
?>
</div>
<div class="col-md">
<h3 class="text-secondary">USER</h3>
<?php
$result=mysqli_query($conn,$query_user);
if(mysqli_num_rows($result)>0){
while ($row=mysqli_fetch_assoc($result)) {
// find artistid from trackid
$username=$row["username"];
echo "<div class='row listitem'>
<div class='col-md'>
<a href='user.php?username=$username'><span class='trackName'>$username</span></a>
</div>
</div><hr class='bg-secondary'>";
}
}
?>
</div>
</div>
</div>
<?php
require_once("includes/optionsMenu.php");
require_once('frame_footer.php');
?>