suhas gawde suhas gawde - 4 months ago 33
MySQL Question

Displaying youtube video from mysql database using php?

I want to display youtube video on a page, the following is my code in order to fetch youtube video URL from the database stored in mysql and then display it by iterating using while loop. However, the iframe does not display any video inside it.

if ($get_result != false) {
while ($row = mysqli_fetch_array($get_result, MYSQLI_ASSOC)) {
<iframe width="560" height="315" src="<?php echo $row["url"]; ?>" frameborder="0" allowfullscreen></iframe>

I have also tried using video tag inside while loop but it does not display the Youtube video inside the video player.
Please help me to solve this issue.


The problem is with your URL value.Replace "watch?v=" in video url with "v/" and try again.For example I tried with

<iframe width="560" height="315" 
src="" frameborder="0" allowfullscreen></iframe> 

The above code will work fine.