SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the mysql/php tutorials (which are great) only text/numeric entries are covered (id's , the jokes, names etc.). But what if you want to get an article from the database which includes an image? Is it possible to to get both the text and (the link to) the image from the database?

  2. #2
    SitePoint Wizard TWTCommish's Avatar
    Join Date
    Aug 1999
    Location
    Pittsburgh, PA, USA
    Posts
    3,910
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    networktm: I believe plain HTML can be entered into an SQL table...so you could just stick the image code in there and try to pull it out of the database...



    ------------------
    Chris Bowyer
    MyCoding.com: Join our mailing list for launch notification!
    "I'm not an insomniac, I'm a web designer."

  3. #3
    SitePoint Member
    Join Date
    Jun 2000
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, if you have a standard image directory and put the filename in the db, it's pretty simple to put it in.

    <img src="path/to/<?php printf($filename); ?>">

    Of course it assumes that you pulled the filename from the db and assigned it to $filename.

  4. #4
    SitePoint Wizard
    Join Date
    Jul 1999
    Location
    Chicago
    Posts
    2,629
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    jwynia's way is the best but images and other binary data can be stored in DBs too. Just use BLOB to store the data. Like...

    CREATE TABLE images (
    //stuff...
    IMAGEDATA BLOB,
    );

  5. #5
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hopefully I'll have time to cover storing binary data in a MySQL database and displaying it as an image in an HTML page. If I don't, I'll be sure to post a link to the information somewhere on the Net.


    ------------------
    -Kevin Yank.
    http://www.SitePoint.com/
    Helping Small Business Grow Online!

  6. #6
    SitePoint Member
    Join Date
    Jun 2000
    Location
    Netherlands
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you all for helping me.


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
  •