选择收藏的视频 - MYSQL

时间:2015-09-02 05:16:47

标签: php mysql

在我的网站中,您可以查看用户喜欢哪些视频。

这是代码......

PHP

     public static function VideosFavoritos($user){
        $sql = "SELECT id, titulo, directorio, imagen, usuario_id FROM video INNER JOIN videos_likes ON videos_likes.video_id = video.id AND videos_likes.id_canal = '$user'";
        $resultado = self::Conexion($sql);
        $videos = array();

        if(isset($resultado)){
            $row = $resultado->fetch();
            while($row != null){
                $videos[] = new Videos($row);
                $row = $resultado->fetch();
            }
        }
        return $videos;
    }

    public static function MostrarVideosFavoritos($user){
        $videos = self::VideosFavoritos($user);

        if(empty($videos)){
            print "<h4>Este usuario no tiene videos favoritos</h4>";
        } else {
            foreach($videos as $video) {
                print "<div class='video_main_container'>";
                    print "<div class='video_container'>";
                        print "<div class='video_thumb'><a data-id='".$video->getID()."'><img src='include/images/videos/video-thumb.png' alt='' /></a></div>";
                        print "<div class='video_info'>";
                            print "<p class='title'>".$video->getTitulo()."</p>";
                            print "<p class='usuario'>".$video->getUsuario()."</p>";
                        print "</div>";
                    print "</div>";
                print "</div>";
            }
        }
    }

MYSQL图片

视频表 = LINK

视频广告 = LINK

sql做得不好......我怎样才能打印出用户喜欢的视频?

已更新

我知道我自己拿到了......

0 个答案:

没有答案