Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help with this simple code, please.

BloodStormBloodStorm Member Posts: 23
[code]
<?php
if ($pictures==NULL) ($pictures="abstract");
$dir=$pictures;
for ($pic=1; file_exists(".images$dir$pictures$pic.jpg"); $pic++) {
echo("<IMG SRC="./images/$display/$pictures$pic.jpg" WIDTH=250 HEIGHT=250>     ");
}
?>
[/code]

I have links on my site to my various galleries (Abstract, Illusion, personal, etc.). I want this code to show all pictures at the same size. Here's how I've got it broken down.


1) It checks the picture variable. If it's NULL (not set) then it goes to abstract by default.
2)it sets the directory variable equal to picture. (the abstract pictures are in the image directory in a folder named "abstract." Each picture is name abstractx.jpg, where x is a number).
3) Begins the loop, setting picture number to one. It looks to see if that picture exists. If it does, it prints the picture on the screen to the specified size, spaces five times, then repeats.

Example:
When first viewing the page, the IF command sets picture to 'abstract.' It sets dir to the same value as picture ('abstract'). It begins the loop. First, it sets pic to 1. Then it checks to see if "./images/$dir/$pictures$pic.jpg" (to begin with, ./images/abstract/abstract1.jpg. If it exists (and it does) then it's supposed to print the picture. Then, it adds one to $pic, and repeats the process.


Whenever I go to run this script, it doesn't work. Can someone please help.

Comments

  • mtman65mtman65 Member Posts: 7
    Looks like you have parenthesis instead of brackets around this statement:

    ($pictures="abstract");

    instead of

    {$pictures="abstract"};



  • mtman65mtman65 Member Posts: 7
    Let me do this, just in case my answer was more confusing than clear:

    if ($pictures==NULL) {
    $pictures="abstract";
    }

    Hope that is clear.




    : Looks like you have parenthesis instead of brackets around this statement:
    :
    : ($pictures="abstract");
    :
    : instead of
    :
    : {$pictures="abstract"};
    :
    :
    :
    :

Sign In or Register to comment.