Jump to content

problem with $_GET and foreach(glob())


arbitter

Recommended Posts

So I have 2 columns, one on the left hand side with:

foreach (glob('*',GLOB_ONLYDIR) as $map)
			{ echo "<tr><td><a href='?month=$map'>$map</a></td></tr>";}

So that all my maps with images (January '10, February '10,...) get shown with link as "uploads/January '10"

Now some problems are with the space, as the script returns

http://localhost/depypere/uploads/uploads.php?month=January

instead of

http://localhost/depypere/uploads/uploads.php?month=January '10

logical, but nevertheless, I tried to fix that. This goes n the right-hand column:

 

$month = $_GET["month"];
$month .= " '10";
foreach (glob('$month/*.jpg') as $image)
{ echo "<center><img src='$image' style='max-width: 70%'></br>";}

 

But that doesn't work at all...

any help?

Link to comment
Share on other sites

foreach (glob('*',GLOB_ONLYDIR) as $map)
{
    $qmap = urlencode($map);
    echo "<tr><td><a href='?month=$qmap'>$map</a></td></tr>";
}

 

The single quote in the variable's value was causing your HTML to be broken. Values going into URLs should be urlencoded so that the constructed URL contains only URL-safe characters (and has the added bonus of fixing your HTML issue).

Link to comment
Share on other sites

Okay I so the url that goes back to my php file is still"/January+'10" (is that bad?)

BUT I do get broken images in my right-column, though the images don't show, they are the right amount of broken-images... I have 10 images in my uploads/ file and I get 10 small boxes as if the files are missing...

Link to comment
Share on other sites

The problem is that the images I want do not get shown...

There are boxes, the same amount as there are photo's, but it's a box as if the image is not in place, though I do get the right amount of boxes as there are images...

$month = $_GET["month"];
			foreach (glob($month . '/*.jpg') as $image)
				{ echo "<center><img src='$image'></br>";}

 

before clicking january; this part is good (if I add directory february '10 it gets shown too)

14y2vzq.jpg

 

After clicking january '10

url: http://localhost/depypere/uploads/uploads.php?month=January+'10

20gnwv9.jpg

 

another question, how do I get jpg/jpeg/gif/pjpeg in one glob?

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.