Re: How to make links?

From: Date: Fri, 26 Jan 2001 09:19:13 +0000
Subject: Re: How to make links?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-36759@lists.php.net to get a copy of this message
> How do make admin site that lists htm documents from directory and i can > define link name to each of these? > So when user comes, he sees link list to these documents, with names i > defined. Something not unlike this might work: [Untested code] create table links( linkid int(11) auto_increment unique not null, title text, directory text, filename text ); <?php exec("/usr/bin/pwd", $results, $error); if ($error){ die("Error $error executing pwd. Usually path/permissions.<BR>\n"); } $directory = $results[0]; $query = "select title, filename from links where directory = '$directory'"; $links = mysql_query($query) or die(mysql_error()); while(list($title, $filename, $url) = mysql_fetch_row($links)){ $link[$filename] = $title; } $dir = opendir($directory); $urldir = substr($directory, strlen("/full/path/to/your/web/root/htdocs/")); while($filename = readdir($dir)){ if (isset($link[$filename])){ echo "<A HREF=$urldir/$filename>$link[$filename]</A><BR>\n"; } else{ echo "<A HREF=$urldir/$filename>$filename</A><BR>\n"; } } ?> -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#36759) next »