How to display video from MySQL database in PHP

by Yogesh Khanna 05-Jun-18

0 7861


Are you confused about how to retrieve the video from the database on your website front end page?

So here's the solution given. To get the video from the database, you require the exact path of the video folder where you have saved the particular video during uploading time.

The entire code of the retrieving video is identical with retrieving images from the database except the path of the video which was illustrated below in detail:


A global function is used to get the value of that variable which is used all over website pages. The global function is integrated into the functions file.

<?php
global $video_path;
$video_path ='video_folder/';

$query = "SELECT * FROM videos WHERE id=1";
$sql=mysqli_query($GLOBALS['db'],$query);
$row=mysqli_fetch_array($sql);
?>

<video width="100%" controls>
<source src="<?php echo $GLOBALS['video_path'].$row['product_video'];?>">
</video>

<!-- Here "controls" is used to get control on video (Start, Stop, Download etc.) -->


RecommendationI would personally suggest you get this book now to enhance your PHP knowledge


Related articles:

1. How to retrieve images from MySQL database

2. Update data in MySQL without change the exists file


Share:


Comments

    Waiting for your comments

Leave a Reply