Search code examples
phpmysqlvideoembedvimeo

Is there a way to display vimeo videos on my website from embedded url in database?


I am trying to create where people can input a video url and it will save into my database. The thing is that after I've saved the video url in my database, how can I show it on the page using PHP?

For example, using this embedded vimeo video, how can I display it after I've called it from my database.

If I want to show it from the database like this:

$result = mysqli_query($connect,"SELECT * FROM web where video <> '' && video IS NOT NULL");

    if ($row = mysqli_fetch_array($result))
    {

How can I display this?

<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&deg; 
        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>

Solution

  • Like this:

    $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&deg; 
        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>