开发者

omit a div if its null

I have a div that looks like this:

<div id="restinfoinn">
  <div id="resthead">Purpose</div>
  <div id="restcontstitle2"><?php echo开发者_运维百科 $row_pages_here['purpose']; ?></div>
</div>

I want it to be omitted if the value of purpose is empty/null. How can I do this?


<?php if (!empty($row_pages_here['purpose'])) : ?>
<div id="restinfoinn">
  <div id="resthead">Purpose</div>
  <div id="restcontstitle2"><?php echo $row_pages_here['purpose']; ?></div>
</div>
<?php endif; ?>

But i think it would be better to print the empty div and deal with the design in CSS


This is really basic. You just need to do an IF check on top.

<?php if (!empty($row_pages_here['purpose'])) : ?>
    <div id="restinfoinn">
      <div id="resthead">Purpose</div>
      <div id="restcontstitle2"><?php echo $row_pages_here['purpose']; ?></div>
    </div>
<?php endif;?>

Have a look at alternative control syntax and empty

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜