Hello everyone,
My name's Daniel and I'm fairly new to PHP. At the moment, I'm trying to make my site more automatic when it comes to adding content and such by using PHP when needed. I'm now trying to make the addition of graphics to my site to be fairly automatic by using the following code:
<?PHP include 'free/signatures/pagination.php'; ?>
<table border="0" width="400" cellspacing="1">
<?PHP
$list_ignore = array ('.','..','images','Thumbs.db','index.php','index2.php','index3.php','pagination.php','error_log');
$direct = getcwd();
$part = explode('/', $direct);
$foldernumber = $part[6];
$handle=opendir("free/signatures/$foldernumber/");
$dirs=array();
$files=array();
$i = 0;
while (false !== ($file = readdir($handle))) {
if (!in_array($file,$list_ignore)) {
if(!eregi("([.]bak)",$file)) {
if(is_dir($file)) {
$dirs[]=$file;
} else {
$files[]=$file;
}
$i++;
}
}
}
closedir($handle);
$tab=array_merge($dirs,$files);
rsort($tab); // change order
if ($i) {
foreach ($tab as $rep) {
if(eregi("([.]gif)|([.]jpg)|([.]jpeg)|([.]png)|([.]bmp)", $rep)) {
$ext="images";
} elseif($rep[folder]==true) {
$ext="folder";
} else {
$ext="text";
}
echo ('<tr>
<td><img src="free/signatures/"$foldernumber"/'.$rep.'" border="0" alt="image" /></td>
</tr>');
}
} else {
echo "No files";
}
?>
</table>
<br /><br />
For some reason, with the code posted above, <img src="free/signatures/"$foldernumber"/'.$rep.'" border="0" alt="image" /> will not echo $foldernumber and $rep. Instead, it simply displays something like http://www.mysite.com/free/signatures/. Before I had added
$direct = getcwd();
$part = explode('/', $direct);
$foldernumber = $part[6];
$handle=opendir("free/signatures/$foldernumber/");
and replaced all instances of 1 with "$foldernumber", the code worked perfectly. I'm very confused why the code won't simply echo the variable.. I'm fairly new to PHP and understand some basics although why this isn't working is completely beyond me. I simply cannot find what the problem is.. Any help would be greatly appreciated.
Thanks,
Daniel