SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict sstaubin01's Avatar
    Join Date
    Nov 2000
    Location
    Ont, Canada
    Posts
    234
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought I read that you can load images (gif or jpeg) into a MySQL database. Is this true or am I dreaming?

    I want to create a table that will have a begin and end date with images. The table will have columns named begindate, enddate, image1, image2, image3. The page using these images will load the images selected from the row where current date >= begindate and <= enddate. This will put different images on the page on different dates.

    I'm using PHP and MySQL. Can this be done? If not, any suggestions on how I can accomplish this?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes it can be done, using a blob field although I would suggect that you just save the image paths to the db to cut dowbn on size and performance of the db.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Wizard edshuck's Avatar
    Join Date
    Jul 2000
    Posts
    1,198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I am using fiction to ask this but it is a real question.

    Lets start with 400 images and each with a thumbnail.

    The naming convention is:

    For the pictures Plate1.gif....Plate400.gif and

    For the thumbnails Plate1tn.gif .... Plate400tn.gif

    The db has 3 tables ID, Plate, thumbnail.

    The select is not a problem for me. I know how to handle them. And I know how to work through many problems with them.

    But the problem follows:

    I want to generate a page with the first 20 images. Number 1 thru 20. So I bring up code that creates an array and loads the array with Plate1tn.gif .... Plate20tn.gif.

    How do I get them to display the thumbnail itself instead of the name and extension. In otherwords, instead of stopping with the name and extension, giving me an actual photo?

    The reason for the question is not retorical. Rather, I have need for graphics in many locations in my pages and this problem is generic enough that the answer will provide signposts to other solutions later.

    Thanks
    <Edited by edshuck on 11-29-2000 at 12:07 PM>

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well since you should already know the location of the images on your server, there are several ways to accomplish this. One would be to just loop through the array of thumbnail names and print out an image tag for each

    while(list($key,$thumb) = each ($arrayname)) {
    printf('<img src="pathtoimages/%s"><br>', $thumb);
    }


    Another would be create a function to do it for you

    function show_thumbs($thumbnailarrayname) {
    while(list($key,$thumb) = each ($thumbnailarrayname)) {
    $return .= sprintf('<img src="pathtoimages/%s"><br>', $thumb);
    }
    return $return;
    }

    Sample Usage:
    print show_thumbs($thumbnailarrayname);
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Wizard edshuck's Avatar
    Join Date
    Jul 2000
    Posts
    1,198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi freddy

    Thanks so much. Not only has this been a problem for me but i do Website Reviews and there are often sites that could really benefit from a db/php solution.

    I have no idea how they can maintain their sites without an automated solution.

    Thanks again


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
  •