[英]php code not working inside html
I am trying to display an image. 我正在尝试显示图像。 I have fetched my URL from the db storage.
我已经从数据库存储中获取了URL。 And i have used the php variable inside the image tag.
而且我已经在image标签中使用了php变量。 But the code does'nt display any image .
但是代码不显示任何图像。
what is the problem? 问题是什么? exactly!
究竟!
this is my code below 这是我的下面的代码
<?php $db =& JFactory::getDBO();
$query88=$sql = "SELECT file_url_thumb FROM fs01_virtuemart_medias WHERE virtuemart_media_id=1 LIMIT 0, 30 ";
$result88 = mysql_query($query88) or die(mysql_error());
?><img src="<?php while($row = mysql_fetch_array($result88)){
echo $row['file_url_thumb'];
echo "<br />";
} ?>" border="0" style="border: 0; vertical-align: top;" />
You are looping over your results and putting them all (each followed by a <br />
inside the src
attribute of an img tag. It seems highly unlikely that that won't 404. 您循环您的结果,并把它们全部(每个后跟一个
<br />
里面 src
img标签的属性,似乎极不可能的,不会404。
You probably want something more like: 您可能想要更多类似的东西:
<ul>
<?php while($row = mysql_fetch_array($result88)){ ?>
<li><img src="<?php echo htmlspecialchars($row['file_url_thumb']); ?>" /></li>
<?php } ?>
</ul>
(With some CSS from an external stylesheet to apply your presentation). (使用外部样式表中的一些CSS来应用您的演示文稿)。
<?php
$db = &JFactory::getDBO();
$query88 = "SELECT file_url_thumb FROM fs01_virtuemart_medias WHERE virtuemart_media_id=1 LIMIT 0, 30 ";
$result88 = mysql_query( $query88 ) or die( mysql_error() );
while( $row = mysql_fetch_array( $result88 ) ) {
echo '<img src="' . $row[ 'file_url_thumb' ] . '" border="0" style="border: 0; vertical-align: top;" /><br />';
}
?>
use this 用这个
<?php
$db = &JFactory::getDBO();
$query88 = "SELECT file_url_thumb FROM fs01_virtuemart_medias WHERE virtuemart_media_id=1 LIMIT 0, 30 ";
$result88 = mysql_query( $query88 ) or die( mysql_error() );
while($row = mysql_fetch_array($result88)){
echo '<img src="'.$row['file_url_thumb'].'" style=" border="0" style="border: 0; vertical-align: top;"/>';
echo '</br>';
}
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.