Jump to content

Images not appearing, no errors (known) in code


NotCool

Recommended Posts

Hi! I'm trying to have a directory of images appear on a page, each image linking to a larger version of that image. The thumbnail is named HPIM*_medium_thumbnail.png and the larger image is HPIM*_medium.jpg. The PHP code was originally meant for creating links, and I changed it around some for the images. (I got the code from a tutorial different site). Here is the code:
[code]<?php function show_image($id)
{
$imgdir = "images/medium/";
global $PHP_SELF, $SCRIPT_NAME;
if (trim($PHP_SELF) == "") $PHP_SELF = $SCRIPT_NAME;
$dir = opendir($imgdir);
if (!$dir) return;
while ($file = readdir($dir))
{
if ( (ereg("^.*\\.jpg$", $file)) and (is_file($file)) )
{
$item = ereg_replace("^(.*)\\.jpg$", "\\1", $file);
$thumb = ereg_replace("^(.*)\\.jpg"."_thumbnail\\.png", "\\1", $file);
echo '<p class="centeredImage"><a href="http://demartinipotterystudio.com/image.php?id='.urlencode($item).'"><img src="images/medium/'.$thumb.'" width="400" height="299" alt="" /></a></p><br />'."\n";
if ($id == $item)
{
echo "<==";
}
echo "<br>\n";
}
}
}
?>[/code]
The function will appear on the page with:
[code]<?php show_image($id)[/code]

I'm using PHP 4.4.4 if that matters.

I have one other question. I would like to have instead of index.php, works.php, etc., just index.php with parameters being passed to it, such as ?id=works, and show the works.php data (it would just be the php function shown above) in the content part of the page. However, when I try to to do this by making the link http://demartinipotterystudio.com/?id=works, and use the function:
[code]<?php function show_content($id)
{
if ($id == "Home") {
include("home.php");
}
elseif ($id == "Works") {
include("works.php");
}
}
?>[/code]
it does accept the parameter because I have a function changing the title of the page and it does change to Works, but it won't include home.php if the id is Home or works.php if the id is Works. Any ideas why?

EDIT: I just changed the function to:
[code]<?php function show_content($id)
{
if ($id == "Home") {
include("home.php");
}
elseif ($id == "Works") {
include("works.php");
}
}
?>[/code]
and now it is accepting home.php, but won't change it to works.php when id is Works.

Thanks for all the help!

BTW, if there is a better way to create an image gallery, ie with mysql, I'm open to it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.