-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
71 lines (43 loc) · 1.92 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
<?php include "nav.php" ?>
<div class="page-content">
<div class="row-col">
<div class="col-lg-9 b-r no-border-md">
<form class='form-group' style="max-width: 90% ;margin-top: 80px; margin-left: 1rem" action='' method='post' enctype='multipart/form-data'>
<input class="form-control" style="margin-bottom: .5rem" type=text size='60' name='tag' placeholder="Enter keyword to search..." required="true" />
<input type='submit' class="btn btn-outline b-black text-black" name='search' value='Search' />
</form>
<div class="padding">
<div id="tracks" class="row item-list item-list-xs item-list-li m-b">
<div class="col-xs-12">
<?php
if (isset($_POST['search'])) {
if (isset($_POST['tag'])) {
$tag = $_POST['tag'];
$query = "SELECT * FROM music WHERE name LIKE '%$tag%'";
};
$search_query = mysqli_query($connection, $query);
if (!$search_query) {
echo "Sorry, Something went wrong";;
}
$count = mysqli_num_rows($search_query);
if ($count == 0){
echo "<h4> No Result</h4><p>Please try another keyword</p>";
}else{
echo "<h5 style='margin-right:.3rem;'><b>" . mysqli_num_rows($search_query) . " Result(s)</b></h5>";
while ($row= mysqli_fetch_assoc($search_query)) {
$id = $row['id'];
$name = $row['name'];
$size = $row['size'];
$downloads = $row['downloads'];
?>
<div class="item r" data-id="item-10">
<div class="item-info">
<div class="item-title text-ellipsis"> <a href="download.php?file_id=<?php echo $id ?>"><?php echo $name ?> </a></div>
<div class="item-meta text-sm text-muted"> <span class="item-meta-right"><a ><?php echo floor($size/1024) ?> MB</a></span> </div>
</div>
</div>
<?php }}} ?>
</div>
</div>
</div>
<?php include "footer.php" ?>