What is this called??

Discussion in 'PHP' started by krebs, Dec 9, 2013.

  1. #1
    I am in the process of creating a PHP based section of my website for photos/descriptions/keywords. I have the uploading and DB processes set, but now I am starting to create the point where when they will click the thumbnail and it takes them to the dynamically created page of just that photo.

    I can't find any tutorials or the command line that I will need for this section of the site. Does it have a name? Each time I search google for this I get websites from people selling books on dynamically created websites and PHP. I dont want to buy a book. I just need to know the direction and I can figure out the rest.

    If I had to guess, the link on the thumbnail would start a php script which takes you to a template page and pulls the info from the DB. But what link do I use for the thumbnail? And what commands do I need to make the thumbnail to then open and populate the template page?

    Thanks in advance
     
    krebs, Dec 9, 2013 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #2
    Lets say you have a database with a table called images. It might have these columns

    id
    name
    actualname

    Name is the name given by the user while actual name is what you've stored it as - something unique so that if two users upload kitten.jpg there won't be a problem.

    Then on your thumbnail display page you'd have a query to get all the relevant image info

    <?php
    foreach($results as $row){
       echo "<div><a href="/singleImage.php?img={$row['id']}'><img src='/thumb.php?img={$row['id']}'></a></div>\n";
    }
    Code (markup):
    your thumb.php script will create (find the cached version if it exists?) thumb of the image and output as an image with appropriate headers. Google "php image thumbnail" for examples.

    your singleImage.php script will display the page and the full sized image.

    Once you have all that written and tested you can look at seo friendly urls and start playing around with .htaccess, but first things first.
     
    sarahk, Dec 9, 2013 IP
  3. krebs

    krebs Greenhorn

    Messages:
    44
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #3
    I have the part where I, as the user, can upload a high quality image, it will the create the thumbnail and save a better quality version in a folder while also storing the text fields inputted with it, a unique ID# and image filename into the DB.

    So, now a viewer will be able to click on the thumbnail from a list, The thumbnail link will be /templatepage.php?id=12
    And that will take them to the single image page.

    Now the blank fields in that templated single image page need to populate with the info from the DB. I would then need to connect to the DB and populate. That is the code I am looking for. I believe it is a GET function using the info from the row id=12.

    I feel like this is such an easy one I am overlooking it..

    Thanks again.
     
    krebs, Dec 10, 2013 IP
  4. sarahk

    sarahk iTamer Staff

    Messages:
    28,897
    Likes Received:
    4,555
    Best Answers:
    123
    Trophy Points:
    665
    #4
    How are you creating your list of thumbnails?
    Surely you are querying the database to create that list?

    so on single you just need
    $id = intval($_GET['id']);
    if ($id) {// ie is greater than 0
    $sql = "select * from `images` where `id` = '{$id}' limit 1";
    }
    Code (markup):
    and then send your query to the script that handles database calls.
     
    sarahk, Dec 10, 2013 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    But, frankly... Creating pages (dynamically or not) for displaying full size images? Have a look at Light Box, or one of its clones
     
    PoPSiCLe, Dec 10, 2013 IP
  6. Darkhodge

    Darkhodge Well-Known Member

    Messages:
    2,111
    Likes Received:
    76
    Best Answers:
    1
    Trophy Points:
    185
    #6
    Darkhodge, Dec 11, 2013 IP