#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Use PHP to auto generate link around image pulled from database


    I have dynamically created links that attach themselves to information pulled from the database.

    Code:
    echo "<a href= 'http://www.website.com/test/link.php?field=".urlencode($imgrow['data'] ) . "'><h3>$imgrow[data]</h3></a>";
    The above works. I wanted to do the same for the following thumbnails:

    Code:
     echo "<img src='".$showimage."' height='203px' width='135px' />";
    What is the code to create an auto-generated link around that image? I tried

    Code:
    echo "<a href= 'http://www.website/link.php?field=".urlencode(img src='".$showimage"' height='10px' width='50px' />) . "'>$showimage</a>";
    but am pretty new at this and can't get it right.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,692
    Rep Power
    6351
    HTML tags are an entirely separate language, and none of them use parentheses. It's all angle brackets.


    PHP Code:
    echo "<a href= 'http://www.website.com/test/link.php?field=".urlencode($imgrow['data'] ) . "'><img src='".$showimage."' height='203px' width='135px' /></a>"
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0

    Excellent


    Thanks!!!!!!!!!!!!! I was beating my head against my desk!
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,692
    Rep Power
    6351
    I took the code in your second example, everything inside the beginning and ending quotes, and pasted it over the <h3> tag in your first example.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    7
    Rep Power
    0
    Originally Posted by ManiacDan
    I took the code in your second example, everything inside the beginning and ending quotes, and pasted it over the <h3> tag in your first example.
    Excellent! I'm still working on that other blank page thing. Going back through my history to find that other solution. I certainly hope it's as easy a solution as I remember.

IMN logo majestic logo threadwatch logo seochat tools logo