Edgardasun Edgardasun - 3 months ago 7x
PHP Question

How to display video files from folder into a php template

I'm trying to accomplish something like this website

As you can see any video that you click on,
takes you to that same page. The only difference is the video playing.

I'm trying to do the same for my website. here is my code

<div class="thumbnail">
<a href="video.php?id=video1">
<img src="/local/images/vid_01.jpg">

<div class="thumbnail">
<a href="video.php?id=video2">
<img src="/images/vid_02.jpg">

<div class="thumbnail">
<a href="video.php?id=video3">
<img src="/images/vid_03.jpg">

This part here I can't quite understand yet.
When a video is clicked on

I should send the user to

and inside that iframe element it should only send the video id.

video1 is click then iframe should be src="media/video1.mp4"

video2 is click then iframe should be src="media/video2.mp4"

video3 is click then iframe should be src="media/video3.mp4"

$id = $_GET['id'];

<section id="video-php">
<iframe src="media/<?php echo $id?>.mp4" allowfullscreen></iframe>

Updated my question.
I have another question.
How can make it so that when a unique video ID
is click, to also included the video title. Is there such tag in php
to make this happen?


You forgot the "echo" before your variable $id. I think that's why it didn't work.

You should use the video tag provided by HTML5. It allows you to insert a video content into your web page.

$id = $_GET['id']; 
<video width="320" height="240" controls>
  <source src="media/<?php echo $id; ?>.mp4" type="video/mp4">
  Your browser does not support the video tag.