从数据库中获取数据后区分div

时间:2017-01-05 07:43:31

标签: php html

我如何区分$ tag,我需要将带有标签性能的视频和带有标签的视频分开。我需要把$ tags = $ sexy放在div sexydiv中,其他div也是如此。我下面的代码只会列出每个列表。我需要让它看起来像youtube主页,其中建议视频和热门视频分为2个div。

<div class="suggested-video">
<h2>Suggestion for you</h2>
    <ul>
    <?php
        global $connection;
        $sexy = "sexy";
        $new = "new";
        $query = "SELECT `videoname`,`username`,`videourl`,`uploaddate`,`duration`,`views`,`tags` FROM `videolist` WHERE `tags` = ? ";
        $stmt = $connection->prepare($query);
        $stmt->bind_param("s",$sexy);
        $stmt->execute();
        $stmt->store_result();
        if($stmt->num_rows > 0){
            $stmt->bind_result($videoname,$username,$videourl,$uploaddate,$duration,$views,$tags);
            while ($stmt->fetch()) {
                if($tags == $sexy){
                echo "
                    <div class='sexydiv'>
                    <ul>
                        <a href='video.php?watch=$videourl'>
                        <li>
                            <div class='leftside'>
                                <img src='' width='100%' height='100%' style='background-color: blue;' >                    
                            </div>

                            <div class='rightside'>
                                <h4>$videoname</h4>
                                <p>$username</p>
                                <p>$views views</p>
                                <p>$duration</p>    
                                <p>$tags</p>                
                            </div>

                        </li>
                        </a>
                    </ul>
                    </div>
                ";                      
                }
                if($tags == $new){
                echo "
                    <div class='newdiv'>
                    <ul>
                        <a href='video.php?watch=$videourl'>
                        <li>
                            <div class='leftside'>
                                <img src='' width='100%' height='100%' style='background-color: blue;' >                    
                            </div>

                            <div class='rightside'>
                                <h4>$videoname</h4>
                                <p>$username</p>
                                <p>$views views</p>
                                <p>$duration</p>    
                                <p>$tags</p>                
                            </div>

                        </li>
                        </a>
                    </ul>
                    </div>
                ";                      
                }

            }
        }
    ?>
    </ul>
</div>

0 个答案:

没有答案