我正在开发一个电影数据库项目,我按照它需要的方式获得了我的数据库,但是它的前端部分存在问题。我终于得到它来显示所有信息并让它可以点击,但我很确定这不是这样做的方法。
我在播放这些类型时遇到了麻烦。我要么可以groupconcat并显示所有这些,但是我不能将它们作为链接,或者我可以单独进行并拥有链接,但不能全部获取它们。我终于得到了所有这些,但是当我在手机或平板电脑上尝试时,我只能看到最后一种类型,而不是其他类型。所以我做了另一个数据库并拉取请求再次获取所有数据,但我很确定这是不对的。
SELECT Movies.Code, Title, Plot, Movies.Type, Movies.Category, Image, Score, Rated, Alt, Status, YearReleased, Duration, SUBSTRING(Duration, 1, CHAR_LENGTH(Duration) - 3) AS Duration2, TotalEps, Types.code as tcode, Types.Type as ttype, Categories.Code as ccode, Categories.Category as ca, Ratings.Code as rc, Ratings.Rating as rr, Genre, GenreCode
FROM Movies, Types, Categories, Ratings, MovieGenres, Genres
WHERE Movies.Type=Types.Code
AND Movies.Rated=Ratings.Code
AND Movies.Category=Categories.Code
AND Movies.Code=MovieGenres.MovieCode
AND MovieGenres.GenreCode=Genres.Code
AND Movies.Code = ?;
SELECT Genre, GenreCode
FROM MovieGenres, Genres
WHERE MovieGenres.GenreCode=Genres.Code
AND MovieCode = ?;
格式化:
[conditions] => Array (
[0] => Array
(
[0] => Site ID
[1] => IN
[2] => Array
(
[0] => 10
)
)
[1] => Array
(
[0] => Subscriptions
[1] => IN
[2] => Array
(
[0] => contests
)
)
[2] => Array
(
[0] => Businesses
[1] => IN
[2] => Array
(
[0] => 2
)
)
)
答案 0 :(得分:0)
您不会循环查询返回的行。
看一下这个答案https://stackoverflow.com/a/160365/6632744
你会想要这样的东西:
while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
echo'<a href="../list/genre.php?GenreCode='. $row['GenreCode'] .'&Genre='. $row['Genre'] .'">'. $row['Genre'] .'</a>';
}
而且你想要删除你的初始提取。
$data = $q->fetch(PDO::FETCH_ASSOC); // remove this line