SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2005
    Location
    Murfreesboro, TN
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Database Image Question

    I have a product database. I have allowed up to six images per product. The image portion which is what I am concerned with works like this:

    pic1 = http://www.mywebsite.com/store/product_images/front.jpg

    pic2 = http://www.mywebsite.com/store/product_images/back.jpg

    etc.

    I have one display module which works for all products based on the product you select:

    To display product 1 in my display.php you code only this:

    <tr>
    <td align="center" valign="center" width="100%">
    <p>[pic1]</p>
    </td>
    </tr>

    The url is picked up from the database as described above.

    What I don't know how to reference in order to be able to click for a larger image are the [pic1] tags etc. If it was a straight <a href with a specified url I would know what to do. I guess my question is what is the syntax of the code I would wrap around [pic1] in order to reference it correctly and display a larger image?

    Instead of this:

    <a href="taco.jpg"><img src="tacot.jpg" width=100 height=25 border=0 alt="click for larger taco"></a>

    How do I introduce [pic1] into the equation?

    I hope this is clear as mud! My first post here and I hope I am in the correct forum....

    Thanks!

  2. #2
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tnchatmonk
    How do I introduce [pic1] into the equation?
    Database:

    Code:
    table: images
    id  name  alt   full_size        thumbnail
    1   pic1  One   /images/pic1.jpg /images_tn/pic1.jpg
    2   pic2  Two   /images/pic2.gif /images_tn/pic2.gif
    3   pic3  Three /images/pic3.jpg /images_tn/pic3.jpg
    4   pic4  Four  /images/pic4.gif /images_tn/pic4.gif
    Input text:

    Code:
    <p>Loriem.... [pic1]</p>
    After parsing:

    PHP Code:
    $picute_name mysql_real_escape_string('pic1'); 
    Which you use in the SQL:

    Code:
    SELECT title, full_size, thumbnail FROM images WHERE name = 'pic1';
    Which you then use to build the HTML:

    PHP Code:
    <a href="<?php echo $full_size ?>">
    <img src="<?php echo $thumbnail ?>
         alt="click for larger <?php echo $title ?>"></a>
    to give:

    HTML Code:
    <a href="/images/pic1.jpg">
    <img src="/images_tn/pic1.jpg" 
         alt="click for larger One"></a>
    hth,
    Douglas
    Hello World

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2005
    Location
    Murfreesboro, TN
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doug,

    Thanks so much for the response. I'll get on it and shake it out!

    Appreciated very much!


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
  •