How to hide images blocks with nothing in them

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tipler

    How to hide images blocks with nothing in them

    i have a search results page and i want it to show images from all my pages. so i have added three echos from database
    Code:
    	<p><img src="images/<?php echo $rsResult['Pic']; ?>" width="250px" height="188px"     <img src="images/<?php echo $rsResult['pictwo']; ?>" width="250px" height="188px"         <img src="images/<?php echo $rsResult['picthree']; ?>" width="250px" height="188px"</p>
    but on some page i only have one image. so on my search results page it shows the firs image but 2 other blank image spots with a image unidentified symbol. is there a code to hide the image blocks if there is no image in them???
  • Death Slaught
    Top Contributor
    • Aug 2007
    • 1137

    #2
    Not with HTML or CSS alone. Perhaps JavaScript can help you.


    Thanks, Death

    Comment

    • JKing
      Recognized Expert Top Contributor
      • Jun 2007
      • 1206

      #3
      Since you are already using php, why not use php to help you.

      Not sure what is in your $rsResult but if it is only the images you could put your code in a for loop that loops through your array.

      If that's not an option wrap each image block in an if statement and check to see if the source is empty before printing.

      Comment

      Working...