dongzi0857
2015-06-27 09:46
浏览 21
已采纳

使用<iframe>时,foreach循环仅返回一个值

Following is the PHP code I'm facing problem with:

<?php 
    $query="SELECT `url` FROM `videos";
    $query_run=mysql_query($query);
    while($row=mysql_fetch_array($query_run)){
        $result[]=$row;}
        foreach($result as $var){
            $url=$var['0'];
            echo "<iframe width='250' height='200' src='".$url."' frameborder='0'>";
        }
?>

The problem is that it returns only one result of <iframe> tag, but echoing out $url i.e

<?php 
    $query="SELECT `url` FROM `videos`";
    $query_run=mysql_query($query);
    while($row=mysql_fetch_array($query_run)){
        $result[]=$row;}
        foreach($result as $var){
            $url=$var['0'];
            echo $url;
        }
?>

returns all the available results.

Please help

图片转代码服务由CSDN问答提供 功能建议

以下是我遇到的PHP代码问题:</ p>

 <  code>&lt;?php 
 $ query =“SELECT`URl` FROM`videos”; 
 $ query_run = mysql_query($ query); 
 while($ row = mysql_fetch_array($ query_run)){
 $ result  [] = $ row;} 
 foreach($ result as $ var){
 $ url = $ var ['0']; 
 echo“&lt; iframe width ='250'height ='200'src =  '“。$ url。”'frameborder ='0'&gt;“; 
} 
?&gt; 
 </ code> </ pre> 
 
 

问题在于 仅返回&lt; iframe&gt; </ code>标记的一个结果</ strong>,但</ strong> 回显 $ url </ code> </ em> ie </ em> </ strong> </ p>

 &lt;?php 
 $ query =“SELECT`URL` FROM`videos`”; 
 $  query_run = mysql_query($ query); 
 while($ row = mysql_fetch_array($ query_run)){
 $ result [] = $ row;} 
 foreach($ result as $ var){
 $ url = $  var ['0']; 
 echo $ url; 
} 
?&gt; 
 </ code> </ pre> 
 
 

返回所有可用的 le results。</ p>

请帮忙</ p> </ div>

1条回答 默认 最新

相关推荐 更多相似问题