在iframe PHP中显示mysql数据库的URL


display URL from mysql database in iframe PHP?

我需要在mysql数据库的php文件中显示iframe的URL。

URL被存储在mysql数据库的一个名为videourl的表和一个名为videourl的列中。

我可以从mysql数据库中获取URL并在php页面上回显它,但我不能将其用作n iframe scr !

下面是我到目前为止所做的:

<?php
echo  "<iframe src='"{$videourl}'" style='"background: #fff;'" frameborder='"0'" height='"450'" scrolling='"auto'" width='"100%'"></iframe>";  

?>

,但由于某些原因,这不起作用。我说它不工作是指它在PHP页面上没有显示任何东西!

最好的方法是什么?

感谢

编辑:这是我的新闻代码,仍然不能工作:

<?php
$con=mysqli_connect("localhost","db_username","password","db_name");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
$result = mysqli_query($con,"SELECT * FROM videourl");

while($row = mysqli_fetch_array($result))
  {
  echo "<td>" . $row['videourl'] . "</td>";
  }
  echo "<iframe src='" . $videourl . '" style='"background: #fff;'" frameborder='"0'" height='"450'" scrolling='"auto'" width='"100%'"></iframe>";
?> 

最后编辑:

好了,我完成了。

如果有人感兴趣,可以这样做:

while($row = mysqli_fetch_array($result))
  {
  $id = $row["id"];
  $videourl = $row["videourl"];
  $date_added = $row["date_added"];
  }
echo  "<iframe src='"{$videourl}'" style='"background: #fff;'" frameborder='"0'" height='"100%'" scrolling='"auto'" width='"100%'"></iframe>"; 

您的错误是忘记设置$videourl的值。

您在$row中获取了结果行。之后,您必须将$row["videourl"]分配给$videourl,否则$videourl将为空,iframe src将为空。

花括号是怎么回事?

echo  "<iframe src='$videourl' style='background: #fff;' frameborder='0' height='450' scrolling='auto' width='100'></iframe>";