首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

请问一个判断有关问题,多谢指导

2012-04-10 
请教一个判断问题,谢谢指导?phprequire(conn.php) $sid$_GET[id] $resultmysql_query(select *

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

<?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" />' : '';

?>

热点排行