href with variable problem

Hi,
i have a small function here, i’m trying to get all file names from a particular folder and display them in a window. Then i href them, made them as links, because all file names are page names, but when i click one of them i get something like this The requested URL /~artbuto/ateitis.ktm.lt was not found on this server.. So the problem is how can i separate the file name from my domain name, that when i click the link i would be directed to ateitis.ktm.lt ?

[php]display_URL();

function display_URL(){

$dir = “/home/artbuto/public_html/sites-available/”;

if ($handle = opendir($dir)) {
echo “Puslapiai:\n”;

/* This is the correct way to loop over the directory. */
while (false !== ($entry = readdir($handle))) {
// Grab first 2 lines of Markdown file
	$content = file($dir . '/' . $entry);
    $title = $content[0];
    $description = $content[1];
	
	if(strpos($title, '# neskelbti') !== false){
}
	else{

    echo "<a href=\"$entry\">$entry</a>\n"; 
	echo "$title\n";
	echo "<html><br></html>";
	}
}

closedir($handle);
}
}[/php]

Try this, it is written for the current directory but will work for subfolders.

[php]<?php
$dir = “.”;
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != “.” && $entry != “…”) {
echo “$entry
”;
}
}
closedir($handle);
}
?>[/php]

thanks, for your help, but it was the same thing. I even put all those link names into database, thought maybe it is the problem, but i get the same problem. Any more suggestions?

found the problem, needed to write http:// before the link

It’s always the simple things.

Sponsor our Newsletter | Privacy Policy | Terms of Service