Announcement

Collapse
No announcement yet.

Picture galleries in php

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dan615
    replied
    PHP Code:
    function print_picture($num$dir "images/set1") { // you can set the default directory to whatever you want
        
    $num intval($num);
        echo 
    '<html><body>';
        echo 
    "<center><img src=\"$dir/${num}.jpg\"></center>";
        if (
    $num != 1) {
            echo 
    "<center><a href=\"image.php?num=" . ($num 1) . "\">&lt; Previous</a>";
       }
       echo 
    " <a href=\"image.php?num=" . ($num 1) . "\">Next&gt;</a></center>";
        echo 
    '</body></html>';
    }

    $num = (isset($_GET['num']) ? $_GET['num'] : 1);
    print_picture($num); 
    That's pretty much the gist (jist/gyst/jyst/whatever) of it. The pictures would have to be named 1.jpg, 2.jpg, 3.jpg, not 001.jpg, 002.jpg, 003.jpg, and so on. It could be done, but it would take some extra coding

    Leave a comment:


  • bob_pitbull
    started a topic Picture galleries in php

    Picture galleries in php

    Hi,

    I was wondering if someone could help me with some php?

    I want to be able to simplify my html for displaying pictures with php. At the moment I have the displaying of pictures working fine, so I can have a line such as the following to open up a new window with an image inside it:-

    <a href="display.php3?image=images/set1/001.jpg" onClick="return popup(this)">
    popup() is a Javascript function.

    So.. what I'd also like to add is the ability to have a "next/previous" ability on the image page. Is there a way that I can pass through 2 parameters, eg. "folder=images/set1" and "pic=1", and then build up the filenames and so use (pic-1) and (pic+1) to change the pic in the window (using Javascript)?

    I'm not sure on either the php or Javascript code to do this :-( ..

    Bob
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X