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

在iframe PHP中显示mysql数据库的URL?,php,mysql,iframe,Php,Mysql,Iframe,我需要在mysql数据库的php文件中显示iframe的URL URL的get存储在mysql数据库中的一个名为videourl的表和一个名为videourl的列中 我可以从mysql数据库中获取URL,并在php页面上回显它,但我不能将其用作iframe scr 以下是我迄今为止所做的工作: <?php echo "<iframe src=\"{$videourl}\" style=\"background: #fff;\" frameborder=\"0\" height=\

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

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

我可以从mysql数据库中获取URL,并在php页面上回显它,但我不能将其用作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>";

?> 

最终编辑:

<?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>"; 
while($row=mysqli\u fetch\u数组($result))
{
$id=$row[“id”];
$videourl=$row[“videourl”];
$date_added=$row[“date_added”];
}
回声“;

花括号怎么了?试试这个

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

错误在于您忘记设置
$videourl
的值


您在
$row
中获取了一个rsult行。在此之后,您必须将
$row[“videourl”]
分配给
$videourl
,否则
$videourl
将为空,并且您的
iframe src
将为空。

实际生成的php是什么?您没有设置$videourl1和“.”连接仅在结束字符串时才起作用。您的原始引用{$videourl1}是正确的,但$videourl1未设置。对不起,我不确定您所说的我未设置$videourl是什么意思!你能解释一下吗?@zgr024,不过我的代码中没有$videourl1这样的东西!没有一个答案可以帮助你,因为你问的问题与解决问题无关……好吧,如果你真的设置了你试图使用的变量的值,这会有所帮助。