日期:2014-05-17  浏览次数:20406 次

请教一个判断问题,谢谢指导

<?php 
require("conn.php");
$sid=$_GET["id"];
$result=mysql_query("select * from jswo where id='$sid' order by id desc limit 0,1");
$rs=mysql_fetch_array($result);
?>
<DIV class=cont>
<H4 class=daystr><?php echo $rs["a1"]; ?></H4>
<DIV class="text w400 bodyleft">
<?php echo $rs["neirong"]; ?></DIV><IMG align=right 
src="<?php echo $rs["img"]; ?>" width=185> </DIV>
<DIV class=bottomy></DIV></DIV>

对于以上代码,现在我有个判断,假设上面IMG字段为空,没有内容,那我想实现<IMG align=right 
src="<?php echo $rs["img"]; ?>" width=185>这段代码就全部不显示,假设IMG字段有数据时,那<IMG align=right src="<?php echo $rs["img"]; ?>" width=185>这段代码就全部显示出来!请问该怎么写呀?谢谢指导!


------解决方案--------------------
<?php

echo !empty($rs["img"]) ? '<img align="right" src="' . $rs["img"] . '" width="185" />' : '';

?>