我有个问题。我想做一个视频画廊,图像缩略图。当你点击缩略图时,一个弹出窗口会显示相应的youtube视频。
我保存在mysql数据库中的唯一youtube id。然而,当我得到我的图库,并点击不同的缩略图,它总是显示相同的视频。当我查看源代码时,会显示正确的youtube id。我不知道出了什么问题。
引导程序3和模态中的youtube
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "DB";
// Make connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connectie mislukt: " . $conn->connect_error);
}
$sql = "SELECT * FROM video ORDER BY id asc LIMIT 0,12";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) {
//Get YT id from DB.
$video = "".$row["video"]."";
if ($result->num_rows > 0) {
echo "
<a href=\"#\" class=\"item-gallery-footer wrap-pic-w\" data-toggle=\"modal\" data-target=\"#modal-video-01\"><img src=\"../images/video/".$row["foto"]."\">
<div class=\"modal fade\" id=\"modal-video-01\" tabindex=\"-1\" role=\"dialog\" aria-hidden=\"true\">
<div class=\"modal-dialog\" role=\"document\" data-dismiss=\"modal\">
<div class=\"close-mo-video-01 trans-0-4\" data-dismiss=\"modal\" aria-label=\"Close\">×</div>
<div class=\"wrap-video-mo-01\">
<div class=\"w-full wrap-pic-w op-0-0\"><img src=\"images/icons/video-16-9.jpg\" alt=\"IMG\"></div>
<div class=\"video-mo-01\">
<iframe src=\"https://www.youtube.com/embed/$video?rel=0&showinfo=0\" allowfullscreen></iframe>
</div>
</div>
</div>
</div></a>
";
}
}
?>
暂无答案!
目前还没有任何答案,快来回答吧!