Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

database has just image filenames, code to point to the path for images folder

  • 23-07-2012 12:10AM
    #1
    Posts: 0 ✭✭✭


    I have searched for this solution on google without success, maybe someone can help me.

    Bought a Gallery and it already has a mysql database so people can upload photos through the backend. I want to use that database (or specific table with images) to show dynamic images throughout the website I designed on other pages.

    It is a website with products.

    This is the code(from a recordset) I used to test a dynamic image from the gallery database on another .php page:

    images/<?php echo $row_Recordset1[‘ImageName’]; ?>

    The database has just the image filenames with no path to each image file. I think that this is a much better way instead of putting a path into the database such as images/photo1 or typing images/ before every dynamic image I want to use.

    What code would I need to insert on a page to point to the images folder so I didn’t have to insert images/ into the code for every dynamic image?

    Many thanks.


Comments

  • Registered Users, Registered Users 2 Posts: 2,238 ✭✭✭techguy


    You need to set a global reference in your site that points to the images root directory.

    Then just prepend that to: $row_Recordset1[‘ImageName’]

    Do you have PHP experience?

    Whats the gallery product you bought? Link?


  • Posts: 0 ✭✭✭ [Deleted User]


    Thanks for the reply.

    This is the gallery.

    http://codecanyon.net/item/sleek-gallery/231637

    The author simply said "You may take a look at function getImage()"

    Very little experience with PHP and thats why Dreamweaver extensions and scripts that I can buy and work through and adapt are the way to go for me.

    EDIT
    Ok I googled your advice and got this link
    http://www.londatiga.net/it/how-to-define-global-absolute-path-in-php/
    Variables is how it is done?.

    Based on above For example if you had your images in media/images in your root directory and just filenames in a field in a mysql database what would your global reference code for your images be?


  • Registered Users, Registered Users 2 Posts: 2,238 ✭✭✭techguy


    The global is a relative path to the "media/images" folder, by relative I mean relative to where the PHP Gallery script is running.

    Example:

    Imagine the PHP gallery is running as a script (.php file) in the folder "website" and the "media" folder also resides in this folder. A relative link to the "images" folder is simply "media/images".

    If you post the directory structure of the script then I should be able to help a little better.


  • Posts: 0 ✭✭✭ [Deleted User]


    Thanks for that.

    I'd prefer to have a general example because I would use that instead of the script as there are a few drawbacks to the gallery.

    I usually do my websites in the following

    root
    - media/images

    I put most of my pages in the root as in index.php, aboutus.php, gallery.php etc.

    I uploaded photos to the server images folder using their upload and they sit in the folders they named:
    media\gallery\photo\large
    media\gallery\photo\thumb

    I then copied their mysql database and copied all of the photos to images/ to test out.
    Like I said I created a recordset:
    images/<?php echo $row_Recordset1[‘ImageName’]; ?>
    It put the first photo on the page but of course didn't work without images/ being inserted before it and didn't work with a repeat region either.

    I just want to be able to insert the global path to the images folder in php so that I can display images from a database like any other data.

    thanks for that.


Advertisement