php - How do I hide the div if the Var is empty? -


i trying hide entire piece of css, field, when result of vr empty. how should done? managed make sure when data empty in database, doesn't display @ all, otherwise does.

<div class="row row_border">     <div class="col-md-2 col-sm-2 col-xs-3"><div class="icon"><span class="icon-tree101"></span></div></div>     <div class="col-md-10 col-sm-10 col-xs-9">         <div class="row">             <div class="col-md-12 col-sm-12"><h4>buitenruimte</h4></div>             <div class="col-md-6 col-sm-6 list_name">                 <?php if (empty(vars::$content->object->data['obw_tuintype'])) { echo "";   } else { echo (vars::$content->object->data['obw_tuintype']); } ?>             </div>         </div>     </div>                              </div> 

that's code have far, thanks.

why not put if statement outside of div? way, if element empty, entire div won't displayed @ all:

<?php if(!empty(vars::$content->object->data['obw_tuintype'])){ ?>     <div class="row row_border">         <div class="col-md-2 col-sm-2 col-xs-3"><div class="icon"><span class="icon-tree101"></span></div></div>         <div class="col-md-10 col-sm-10 col-xs-9">             <div class="row">                 <div class="col-md-12 col-sm-12"><h4>buitenruimte</h4></div>                 <div class="col-md-6 col-sm-6 list_name">                     <?php echo (vars::$content->object->data['obw_tuintype']); ?>                 </div>             </div>         </div>                                  </div> <?php } ?> 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -