hide image if image does not exist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • developing
    New Member
    • Mar 2007
    • 110

    #1

    hide image if image does not exist

    hey,

    im sorta new to php but it seems easy enough...what i wanna do is have php check mysql db to see if a field is empty (got that part covered).

    if, the field is empty then hide an image on the page and move everything else up. If not, then resize the frame to the image's proprtions

    thanks a lot
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, developing.

    I take it you are storing images in the DB?

    Easier way to think about it is that you *don't* output the image unless the field is not empty. Browsers will also automatically determine the proper size of the image.

    Comment

    • developing
      New Member
      • Mar 2007
      • 110

      #3
      Originally posted by pbmods
      Heya, developing.

      I take it you are storing images in the DB?

      Easier way to think about it is that you *don't* output the image unless the field is not empty. Browsers will also automatically determine the proper size of the image.
      well no, im not a big fan of DBing the images, so the db only contains the link to the image rather than the image itself....the image is hosted on my server (same as the site)...

      Comment

      • code green
        Recognized Expert Top Contributor
        • Mar 2007
        • 1726

        #4
        well no, im not a big fan of DBing the images, so the db only contains the link to the image rather than the image itself
        Excellent. I believe in this myself. Using BLOB fields swell the database unnecessarily.
        if, the field is empty then hide an image on the page and move everything else up. If not, then resize the frame to the image's proprtions
        Why not test the variable in php and create or don't create the image HTML depending whether the variable is empty
        [PHP]if(!empty($row['picture']))
        echo HTML to display picture[/PHP]
        Last edited by code green; Jul 12 '07, 11:05 AM. Reason: Accidentlal submit

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Heya, developing.

          Please do not double-post. Thanks!

          Comment

          • developing
            New Member
            • Mar 2007
            • 110

            #6
            woops! my bad, couldnt find this one...

            but thanks for your replies guys...i already had the if statement to check for image existance, including the html made life waay easier....pure genius

            Comment

            Working...