Variable Visions

Articles MySQL PHP-IF-statement-for-hidding-NULL-fields-from-a-MySQL-database


tutorials - MySQL and Web-Development.

PHP IF statement for hidding NULL fields from a MySQL database

Published Tue. Jul. 31, 2012


This if statement will hide the image container when the result is NULL.

<?php
        if ($row_new['introimage'] != NULL) {        
        ?>
       
        <div class="masquehome">
            <a href="<?php echo $row_new['introimage'];?>" class="image lightbox">
            <img class="imageviewhome" id="imageviewhome" src="<?php echo $row_new['introimage'];?>" alt="" />
            </a>
        </div><!-- end masquehome -->
     
          <?php
          }
        ?>

 

 

Well look into TRIM and === next time.


Tag(s): PHP, IF statement, NULL