A
Anonymous
Guest
Hello,
I am fairly new to PHP though i have several years of HTML, and CSS. I am attempting to have my php code read a directory on my server and then spit the results of the directory contents back out as genrated links on the pages. The code is simple and i have implemented it but it only seems to be semi working. Anybody possible can help?
Code being used (Partial, only that related to the issue)
<?php
$dir = "/assets/files/";
// Open a known directory, and generate the download links.
if (is_dir($dir)) {
if ($db = opendir($dir)) {
while (($file = readdir($db)) !== false) {
if ($file != "." && $file != "..") {
$dblisting .= '<li><a href="'.$file.'">'.$file.'</a></li>';
}
}
closedir($db);
}
}
?>
<h1>Downloads Available:</h1>
<ul><?php echo $dblisting; ?></ul>
And i have included a snapshot of what the finished product comes out as. You'll notice that while it shows the H1 tag of the code it does not php echo the $dblisting.
*NOTE* The blue mark out is merely me marking out a portion of my footer.

I am fairly new to PHP though i have several years of HTML, and CSS. I am attempting to have my php code read a directory on my server and then spit the results of the directory contents back out as genrated links on the pages. The code is simple and i have implemented it but it only seems to be semi working. Anybody possible can help?
Code being used (Partial, only that related to the issue)
<?php
$dir = "/assets/files/";
// Open a known directory, and generate the download links.
if (is_dir($dir)) {
if ($db = opendir($dir)) {
while (($file = readdir($db)) !== false) {
if ($file != "." && $file != "..") {
$dblisting .= '<li><a href="'.$file.'">'.$file.'</a></li>';
}
}
closedir($db);
}
}
?>
<h1>Downloads Available:</h1>
<ul><?php echo $dblisting; ?></ul>
And i have included a snapshot of what the finished product comes out as. You'll notice that while it shows the H1 tag of the code it does not php echo the $dblisting.
*NOTE* The blue mark out is merely me marking out a portion of my footer.
