Search code examples
phpcssimagefeed

open picture links in new page with php


I have the code to dump pics in a directory and produce the result in a feed like instagram, i just want it to open the image onto a page with css and area for the picture already plotted out. I just need a jumping off point to open the images individually.


Solution

  • I hope this helps:

    <?php
        $dest = "index.php?id=" . SHOWPIC . "&path=" . $path;
    ?>
    <a href="<?php echo $dest; ?>">
        <img alt="Photo" src="<?php echo $path;?>">
    </a>
    

    SHOWPIC here is a constant that contains an integer. index.php should have something like:

    if($_REQUEST["id"] == SHOWPIC)
        require_once "showpic.php";
    

    $path in my example is meant to contain the path to the image displayed.

    showpic.php will then read the contents of $_REQUEST["path"] and display the pic. That's also the place where you can add CSS or whatever you like to the site.