summaryrefslogtreecommitdiff
path: root/search.php
blob: 45ddf067398f4672374cbe016c1241299b45309b (plain)
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
<html> 

<head>
<title>Dachai's Music</title>
<link rel="icon" type="image/x-icon" href="./res/dachai.ico">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, target-densityDpi=device-dpi">
<link rel="stylesheet" href="./res/styles.css">
<script src="./res/main.js"></script>
</head>

<body> 
<div id="container"> 
    <div id="container-uppper"> 
        <?php include_once('music.php');?>
        <?php include_once('header.php');?>
        <?php include_once('titlebar.php');?>
        <?php include_once 'config.php'?>
        <?php include_once 'utils.php'?>
        <?php 
            $type = $_GET['type']; // 'tag', 'name'
            $value = $_GET['value']; // tag id, name
            $current_page_index = $_GET['page']; // page从0开始
        ?>
        <div id="search-condition">
        <?php 
            $musiclist = null;
            if($type == "tag") {
                echo '<label class="search-hint">Tag : </label>';
                $tag = fetch_tag_by_id($value);
                echo '<label class="search-value">' . $tag->name . "</label>"; 
                $musiclist = fetch_musics_by_tag($tag->uid, $current_page_index * Config::$music_per_page, Config::$music_per_page);
                $url = "./search.php?type=tag&value=" . $value;
                $total_page = ceil(get_music_count_by_tag($tag->uid) / Config::$music_per_page);
            }
            else if($type == "name") {
                echo '<label class="search-hint">Searching : </label>';
                echo '<label class="search-value">' . $value . "</label>"; 

                $musiclist = fetch_musics_by_name($value, $current_page_index * Config::$music_per_page, Config::$music_per_page);
                $url = "./search.php?type=name&value=" . $value;
                $total_page = ceil(get_music_count_by_name($value) / Config::$music_per_page);
            }

        ?>
        </div>
        <?php include_once('musiclist.php');?>
        
    </div>

    <?php include 'paginate.php' ?>

</div>
</body>

</html>