我正在尝试创建人们可以输入视频网址的位置,它将保存到我的数据库中。问题是,在我将视频网址保存到我的数据库后,如何使用PHP在页面上显示它?
例如,使用此嵌入式vimeo视频,如何在从数据库中调用它后显示它。
如果我想从数据库中显示如下:
$result = mysqli_query($connect,"SELECT * FROM web where video <> '' && video IS NOT NULL");
if ($row = mysqli_fetch_array($result))
{
如何显示?
<iframe src="https://player.vimeo.com/video/90312869" width="500" height="281"
frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen>
</iframe>
<p><a href="https://vimeo.com/90312869">360°
Video using 6 GoPro Cameras - spherical panorama timelapse</a>
from <a href="https://vimeo.com/j0n4s">j0n4s</a> on <a href="https://vimeo.com">Vimeo</a>.</p>
答案 0 :(得分:3)
像这样:
$result = mysqli_query($connect,"SELECT * FROM web where video <> '' && video IS NOT NULL");
if ($row = mysqli_fetch_array($result))
{
$url = $row['url'];
}
<iframe src="<?php echo $url; ?>" width="500" height="281"
frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<p><a href="<?php echo $url; ?>">360°
Video using 6 GoPro Cameras - spherical panorama timelapse</a>
from <a href="https://vimeo.com/j0n4s">j0n4s</a> on <a href="https://vimeo.com">Vimeo</a>.</p>
答案 1 :(得分:0)
在html 5中我会像这样写
<?php
// get the url
$sourceURL = value of the extracted column from your table which is a url;
//Extract the file name
$fileName = new SplFileInfo::getFilename ( $sourceURL );
// Get the file extention
$fileExtention = new SplFileInfo::getExtension ( $fileName );
$sourceHTML = '<source src='.$sourceURL.' type="video/'.$fileExtention.'">';
?>
<video width="400" controls>
<?php echo $sourceHTML; ?>
Your browser does not support HTML5 video.
</video>