how to display video from MySQL database in PHP

Are you confused that how to show the video from database at your website page? So here’s the solution given. First of all, to get the video from database you need the path of the video folder where you have saved the video when you had uploaded it.




global is used to get the value of that variable which is used with it at all over pages. You can put it in your 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.) -->

Related Articles:

1. How to retrieve images from MySQL database

2. Update data in MySQL without change the exists file

3. Select Data from MySQL

Leave a Reply

avatar
  Subscribe  
Notify of