bartexsz
bartexsz

Reputation: 259

PHP Gallery not working

I'm creating PHP gallery for my website. It will be displayed inside iFrame inside of normal HTML page.

<html>
<head><title></title></head>
<body>
<table><tr>
<?php
define('Photo_dir','img');
define('Columns',2);
$x=0;
$y=0;
$results = scandir(Photo_dir);
foreach ($results as $result) 
{
    if ($result === '.' or $result === '..') continue;
    if (is_dir(Photo_dir.'/'.$result))
    {
        if($y > 2)
        {
            echo "</tr><tr>";
            $y=0;
            $x=&x+1;
        }
        echo "<td><img src='image.php?photo=".Photo_dir."/".$result."/1.jpg'/></td>";
        echo "kod w html";
    }
}
?>
</tr>
</table>
</body>
</html>

For some reason it is not working. Browser doesn't even see <table>

Thanks in advance.

Upvotes: 0

Views: 170

Answers (2)

froddd
froddd

Reputation: 362

You have a typo in there, on the line where you increment the variable $x you're trying to increment &x. It should be:

$x = $x +1;

Another easy way to increment variables by one is to do:

$x++;

As for the reason you're not seeing any output at all, it looks like it's a 500 error (that's what Chrome reports anyway), which means the server itself is doing a boo-boo. Check your server configuration.

Upvotes: 1

Fluffeh
Fluffeh

Reputation: 33512

Assuming that the constants and variables all old the right information, aren't you missing the opening quote:

<img src='image.php?photo=".Photo_dir."/".$result."/1.jpg'/>
         ^ that one.

Upvotes: 2

Related Questions