Making a list as links
Posted: Mon Mar 27, 2006 1:10 am
feyd | Please use
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Sorry this is probably a simple question. I want to make a php page that will automatically list all the files (usually .bat, .vbs, and exe) in a directory. I'm using a while loop to make the list but I want to also make the list as links with the while loop is that possible? I don't want to manually add each file as a link with <a href> Here's what I have so far, any suggestions is greatly appreciated.Code: Select all
<?
$dir_name="/Inetpub/wwwroot/";
$dir=opendir($dir_name);
$file_list="<ul>";
while ($file_name=readdir($dir))
{
if (($file_name!=".") && ($file_name!=".."))
{
$file_list .="<li> $file_name";
}
}
$file_list .="</ul>";
closedir($dir);
?>Code: Select all
<html>
<body>
<p>Files in: <? echo "$dir_name"; ?></p>
<p><? echo "$file_list"; ?></p>
</body>
</html>feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]