So I am trying to create a gallery that calls up links based on folders, then in turn makes those links load that images in the script. My issue, is that since the page only ‘loads’ one time, the function generation works, but needs to be process one more time with the rest of the code in order to work (e.g. if i were to place the output directly into the page and make hard-links lower down in the script, the page would work… but the idea is not to have hard links). Help would be really appreciated as I have only worked with PHP in regards to editing WordPress themes…
Here’s the page:
<?php$dir = “albums/”;
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($album = readdir($dh)) !== false) {
if ($album!= “.” && $album!= “…” && $album!=".DS_Store") {echo "<?php function $album(){ \$dirp = \"albums/$album/\";
if (is_dir($dirp)) {
if ($dhp = opendir($dirp)) {
while (($filep = readdir($dhp)) !== false) {
if ($filep!= “.” && $filep!= “…” && $filep!=".DS_Store") {echo \"<td><img class='gallery' src='\" . \$dirp . \$filep . \"' /></td>\"; } } closedir(\$dhp); }
}
} ?>
";
}
}
closedir($dh);
}
}?>
<?php $dir = "albums/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($album = readdir($dh)) !== false) { if ($album!= "." && $album!= ".." && $album!=".DS_Store") { echo "
- $album
"; } } closedir($dh); } } ?><! This is the script where the gallery function physically runs --!>
<?php
if (isset($_GET[‘run’])) $linkchoice=$_GET[‘run’];
else $linkchoice=’’;switch($linkchoice){
case ‘pioneering’ :
pioneering();
break;case ‘second’ :
mySecond();
break;default :
echo ‘no run’;}
?>
<! End Script --!>