SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Image slideshow with php and mysql.

    Hi all

    I posted this on another forum but I just wanted to make sure, and also confirm.

    Is it possible to do this:
    Have a folder setup, for example, /img/r1/
    Within that folder will be images in consecutive order.

    Then, in my php file, to read those images and display then in a slideshow. However, I will have different php files with different images. For example, I have www.site.com/hey?id=1, is it possible to use this id= and then tell the script to read images from the /r1/ folder, and if I have a page www.site.com/hey?id=5, the script will read images from /r5/ folder?

    Thanks.

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,407
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    Then, in my php file, to read those images and display then in a slideshow. However, I will have different php files with different images. For example, I have www.site.com/hey?id=1, is it possible to use this id= and then tell the script to read images from the /r1/ folder, and if I have a page www.site.com/hey?id=5, the script will read images from /r5/ folder?
    Yes use $_GET

    If you want an automated sideshow you would probably need to use Javascript - there are a lot of nice jquery ones. You can add the files to the jquery file with php which would be easier than writting each jquery file for each slideshow.

    If the slideshow is to be a sort of click on button for next image that could be done with php.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi. Are there any detail on $_GET? Also, a reply from anotherforum showed this:
    <?php
    $allowedFolders =array( 'r1','r2','r5' );

    if(
    !empty( $_GET['id'] ) // if the folder I'd is specified
    && in_array( $_GET['id'],$allowedFolders ) // and folder is allowed
    ){
    /* get photos */
    }else{
    /* do default action (e.g., maybe a menu or something) */
    }
    Would this work like I wanted? because I couldn't really understand the part to get photos, and what actually
    !empty( $_GET['id'] ) // if the folder I'd is specified
    && in_array( $_GET['id'],$allowedFolders ) // and folder is allowed
    does...

  4. #4
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,407
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    PHP Code:
    $allowedFolders =array( 'r1','r2','r5' ); 
    This is a bit of security to prevent people looking at other folders you do not want them looking into.

    Here is a link to GET in the php manual

    PHP Code:
    !empty( $_GET['id'] ) // if the folder I'd is specified
     
    && in_array$_GET['id'],$allowedFolders // and folder is allowed 
    Is checking the folder you are getting the images from is allowed to be accessed.


    You need a lot more code than you have posted; as I said that is just a basic bit of security checking.

    As I said depending on what you want to do dictates what you do next.

    If I was you I would check out some ready made code on Hotscripts.


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
  •