SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Images/PHP and MySql? How does it work?

    Hi Everyone,

    I'm not entirely sure how images would work with php. The images these types of websites have (below) do you believe the images are stored in a mysql database and called like everything else or are they stored differently? If so, how are they called?

    <snip>picture of a car</snip>
    <snip>picture of a truck</snip>

    Thanks Everyone!
    Last edited by ServerStorm; Aug 28, 2012 at 13:28. Reason: removed promotional inks not needed to ask the question

  2. #2
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Hi scm22ri,

    The recommended method of storing images in the database is to have your images located on your web-folder - say a path might be /var/www/my_site_folder/catalogue_images/.

    You then store any uploaded automobile images in the catalogue folder and you store the web path in the database, so let say your domain is www.my_site.com then you would loop through or select a model of car (in the database) and grab its' image name and then using php append the path together.
    PHP Code:
    $image_path "./catalogue_images/$my_selected_image_name_from_the_db"
    then where you need to display it:
    PHP Code:
    $image "<img src='$image_path' alt='$my_short_description_from_the_db' /> 
    Hope this helps.

    Steve
    ictus==""

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Steve. That was helpful.

  4. #4
    SitePoint Member blogaddition's Avatar
    Join Date
    Sep 2012
    Location
    India
    Posts
    23
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    We can also store the images in mysql database by converting them into binary data and then we have to make our database table image field "blob" type. and the image is stored but that is not better option. ServerStorm has answered correct.

    Thanks


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
  •