Page 1 of 1

(solved)handling images are tough!

Posted: Thu Aug 25, 2005 2:20 am
by lostinphp
the following code displays all the images in folder "thimg"

Code: Select all

<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR">
<title>Everything Graphik Image Gallery</title>
</head>

	<body bgcolor="#F0F0E8" a:hover="#6F6F69" a:linked="#6F6F69">
		<center>
			<br>
			<br>
			<table width="800" border="0">
				<tr>
					<td width="56%"><img src="logo.jpg"></td>
					<td width="44%" align="right"><font color="#6F6F69" face="Verdana, Arial, Helvetica, sans-serif" size="-4">everything graphik, site personnel d'antoine ricardou. plus d'infos sur <a href="http://www.be-poles.com">www.be-poles.com</a></font></td>
				</tr>
			</table>
			
<p align="left"><font color="#6F6F69" face="verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Month/Year <a href="#">back</a>    <a href="#">next</a></font></p>
			
<?php
$a = '0';
$filepath = "thimg";
$url_path = "upimg";
$dir = dir($filepath);
echo "<table border=\"0\" cellpadding=\"5\" cellspacing=\"5\" width=\"75%\">";
while($entry=$dir->read()) 
{
    if($entry == "." || $entry == "..") { 
        continue; 
    } 
    $fp = @fopen("$filepath/$entry","r");
if ($a == '1') {echo "<tr>";}
if ($a == '11') {echo "<tr>";}
if ($a == '21') {echo "<tr>";}
if ($a == '31') {echo "<tr>";}
?><br>
		</center>
		<div align="center">
			<center>
				<td width="40"><a href="display.php"><img src='<? print"$filepath/$entry" ?>' alt="<? echo $entry ?>"></a></td>
				<? $a = ($a + 1);
				}
?>
</tr>

</table></center>
		</div>
	</body>

</html>
the next one display.php is supposed to show only the particular large image when clicked on its thumbnail.instead displays all the images in "upimg" folder..which is fair cos the codes say so too..now i know i have to pass some parameters so dat it displays only one image at a time when clicked on its thumbnail..how do i do it? i mean i dont get the very concept of passing parameters..i looked up on the net..but the explanations are very vague..

Code: Select all

<?php
$url_path = "upimg";
$dir = dir($url_path);
while($entry=$dir->read()) 
{
    if($entry == "." || $entry == "..") { 
        continue; 
    } 
    //$fp = @fopen("$url_path/$entry","r");
?>
		
			<center>
				<a href="image.php"><img src='<? echo"$url_path/$entry"?>' alt="<? echo $entry ?>"></a>
				<? 
				}
?>
		</center>
can anyone here please explain wat i ought to be doing?
thank u

Posted: Thu Aug 25, 2005 2:54 am
by JayBird
put the parameter in this line in your first script.

Code: Select all

<td width="40"><a href="display.php?img=$entry"><img src='<? print"$filepath/$entry" ?>' alt="<? echo $entry ?>"></a></td>
then in your display script, someting simple like.

Code: Select all

$imagename = $_GET['img'];
$url_path = "upimg"; 

echo "<center>";
echo "<a href=\"image.php\"><img src=\"$url_path/$entry\"></a> ";
echo "</center>";

Posted: Thu Aug 25, 2005 3:39 am
by lostinphp
made the modifications
still not working :roll:

Posted: Thu Aug 25, 2005 3:44 am
by JayBird
lostinphp wrote:still not working :roll:
...Doesn't help me help you :roll:

Posted: Thu Aug 25, 2005 3:57 am
by lostinphp
i made the modifications and its still acting the same way!
looks like it has a mind of its own!
thanks a lot though!

Posted: Thu Aug 25, 2005 7:53 am
by feyd
might want something like this more:

Code: Select all

$imagename = $_GET['img'];
$url_path = "upimg";

echo "<center>";
echo "<a href=\"image.php\"><img src=\"$url_path/$imagename\"></a> ";
echo "</center>";

Posted: Thu Aug 25, 2005 8:15 am
by lostinphp
of course i did.
:(

Posted: Thu Aug 25, 2005 9:03 am
by lostinphp
works!!!
thanks for the suggestions! :D