Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    May 2012
    Posts
    153
    Thanks
    115
    Thanked 0 Times in 0 Posts

    I am trying to include an "alt tag" while displaying images from database

    I am displaying my images from a database. I am also displaying a short description ($shortDescription) for each image.

    I would like to include an alt tag for each image (using my $shortDescription variable), but cannot figure out how to add an alt tag in the echo statement.

    When I refresh my website page, and view my source code, I do not see an "alt tag" in my code.
    Also, when I disable images in my browser, I do not see alt tag text, so I must be coding my line wrong.
    I would appreciate your help.

    Here is my code:
    Code:
    echo "<img src='images/products/".$picture_name."' width='275' style='border:solid 5px #ded79e;'>";
    I tried
    PHP Code:
    echo "<img src='images/products/".$picture_name."' width='275' alt='$shortDescription' style='border:solid 5px #ded79e;'>"

  • #2
    Regular Coder
    Join Date
    Jun 2009
    Posts
    146
    Thanks
    3
    Thanked 21 Times in 21 Posts
    It should work, have you set the variable corretly?? Ie. is there empty alt tags showing, this would indicate you have not declared the variable. Also if you code with notices on this would be evident from the notice you get on the page.

  • Users who have thanked itxtme for this post:

    Eggweezer (07-16-2014)

  • #3
    Regular Coder
    Join Date
    May 2012
    Posts
    153
    Thanks
    115
    Thanked 0 Times in 0 Posts
    Thank you itxtme.
    You are right. I fubbed the variable! I appreciate you taking the time to respond to me. Thanks again!


  •  

    Posting Permissions

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