SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Jul 2003
    Location
    england
    Posts
    819
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Question Styles in PHP Code

    I'm trying to implement a border to an image, if there is an image within a database. I currently have this:

    HTML Code:
    <div style="margin-top: 10px;"><span style="float: left; display: inline; border-top: 3px solid #666; border-right: 4px solid #000; border-bottom: 4px solid #000; border-left: 3px solid #666; margin: 0px 10px 10px 0px;">
    
    <?php if (!empty($row_getAdminSupStaffDetailDetail['staff_photo'])) { echo '<img src="../images/photos/' . $row_getAdminSupStaffDetailDetail['staff_photo'] .'" '. getDims($row_getAdminSupStaffDetailDetail['staff_photo'], '../images/photos/') .' '. 'alt="'. $row_getAdminSupStaffDetailDetail['staff_photo_alt'] .'" />'; } ?></span></div>
    But this obviously doesn't work because if there is no image, I still get a border! grrrr....

    Any suggestions?

    Thank you!
    toad78

  2. #2
    Use The Cloud
    Join Date
    Jan 2006
    Location
    Boise, ID
    Posts
    556
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by toad78 View Post
    I'm trying to implement a border to an image, if there is an image within a database. I currently have this:

    <div style="margin-top: 10px;"><span style="float: left; display: inline; border-top: 3px solid #666; border-right: 4px solid #000; border-bottom: 4px solid #000; border-left: 3px solid #666; margin: 0px 10px 10px 0px;">

    <?php if (!empty($row_getAdminSupStaffDetailDetail['staff_photo'])) { echo '<img src="../images/photos/' . $row_getAdminSupStaffDetailDetail['staff_photo'] .'" '. getDims($row_getAdminSupStaffDetailDetail['staff_photo'], '../images/photos/') .' '. 'alt="'. $row_getAdminSupStaffDetailDetail['staff_photo_alt'] .'" />'; } ?></span></div>

    But this obviously doesn't work because if there is no image, I still get a border! grrrr....

    Any suggestions?

    Thank you!
    toad78
    You're setting the border outside of the condition to check for an image.

    You know, if you use whitespace and better variable names programming is much easier.

    Remove the border from your container and add it to your conditional image tag.
    Brad Hanson, Web Applications & Scalability Specialist
    ► Is your website outgrowing its current hosting solution?
    ► PM me for a FREE scalability consult!
    ► USA Based: Available by Phone, Skype, AIM, and E-mail.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •