我正努力让这项工作在这里, 当用户点击任何id视频链接时 我希望该视频也能够拥有它独特的标题 根据视频并在网页上显示?
//index.php
<div class="thumbnail">
<a href="video.php?id=video1" title="I'am video 1!">
<img src="/local/images/vid_01.jpg">
</a>
</div>
<div class="thumbnail">
<a href="video.php?id=video2" title="I'am video 2!">
<img src="/images/vid_02.jpg">
</a>
</div>
<div class="thumbnail">
<a href="video.php?id=video3" title="I'am video 3!">
<img src="/images/vid_03.jpg">
</a>
</div>
//video.php
$id = $_GET['id'];
$idTitle = $_GET['title];
<section id="video-php">
<iframe src="media/<?php echo $id?>.mp4" allowfullscreen></iframe>
<div id="video-info">
<?php echo $idTitle ?>
</div>
答案 0 :(得分:1)
如果您想坚持使用相同的通用方法,可以为链接添加标题:
href="video.php?id=video2&idTitle=Hello%20World
那么这应该输出'Hello World'
<?php echo $idTitle ?>
答案 1 :(得分:1)
<?php $videos = [['title' => 'I am title 1', 'video' => 'video_0.mp4']]; ?>
将所有数据放入上面的数组中。
href="video.php?id=0"
<?php $id = $_GET['id']; $video = isset($videos[$id]) ? $videos[$id] : ['title' => '', 'video' => '']; echo $video['title']; ?>