Jump to content


Photo

opendir question


  • Please log in to reply
3 replies to this topic

#1 techker

techker
  • Members
  • PipPipPip
  • Advanced Member
  • 748 posts

Posted 15 August 2006 - 11:31 AM

hey guys i have this:

<html>
 <head>
 <title>Listing 10.14 Listing the contents 
 of a directory with readdir()</title>
 </head>
 <body>
  <?php
  $dirname = "./updates";
  $dh = opendir( $dirname ) or die("couldn't open directory");
 
 while ( ! ( ( $file = readdir( $dh ) ) === false ) ) {
   if ( is_dir( "$dirname/$file" ) )
     print " ";
   print "$file <br>";
 }
 closedir( $dh );
 ?>
 </body>
 </html>

but i need to link the file?cause now it is juste showing what is in there.

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 15 August 2006 - 11:40 AM

As easy as adding in the anchor tag.
<html>
 <head>
 <title>Listing 10.14 Listing the contents 
 of a directory with readdir()</title>
 </head>
 <body>
  <?php
  $dirname = "./updates";
  $dh = opendir( $dirname ) or die("couldn't open directory");
 
 while ( ! ( ( $file = readdir( $dh ) ) === false ) ) {
   if ( is_dir( "$dirname/$file" ) )
     print " <a href='$dirname/$file'>$file</a> <br>";
 }
 closedir( $dh );
 ?>
 </body>
 </html>


#3 techker

techker
  • Members
  • PipPipPip
  • Advanced Member
  • 748 posts

Posted 15 August 2006 - 11:49 AM

nice it is the print that i was foregetting!lol

#4 techker

techker
  • Members
  • PipPipPip
  • Advanced Member
  • 748 posts

Posted 15 August 2006 - 11:52 AM

funny i get this

http://s88803650.onl...e.us/music9.php

it links the hole directory not the files?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users