How to display video from MySQL database in PHP
×


How to display video from MySQL database in PHP

25046

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

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 for 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.) -->



Recommended Topics 



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments