Outputing a directory >> Small problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
HxJ
Forum Newbie
Posts: 2
Joined: Tue Jul 05, 2005 11:54 pm

Outputing a directory >> Small problem

Post by HxJ »

Hi!

I'm trying to configure this code that outputs a directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  &lt;tr&gt;
                     &lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo; $file&lt;getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo &quote;
                  &lt;tr&gt;
                     &lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo; $file&lt;/a&gt;&lt;/td&gt;
                  &lt;/tr&gt;&quote;;
         }

      }

      closedir($handle);

   }

?&gt;
This still outputs:

>> .
>> ..
>&am($file = readdir($handle))) {

if($file != "." || $file != "..") { // for some reason, this has no affect.

echo &quote;
&lt;tr&gt;
&lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo; $file&lt;/a&gt;&lt;/td&gt;
&lt;/tr&utputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != &quote;.&quote; || $file != "..") { // for some reason, this has no affect.

            echo &quote;
                  &lt;tr&gt;
                     &lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != &quote;.&quote; || $file != &quote;..&quote;) { // for some reason, this has no affect.

            echo &quote;
                  &lt;tr&gt;
                     &lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo; $file&lt;/a&gt;&lt;/td&gt;
                  &lt;/tr&gtto configure this code that outputs a directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != &quote;.&quote; || $file != &quote;..&quote;) { // for some reason, this has no affect.

            echo &quote;
                  &lt;tr&gt;
                     &lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo; $file&lt;/a&gt;&lt;/td&gt;
                  &lt;/tr&gt;&quote;;
         }

      }

to configure this code that outputs a directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != &quote;.&quote; || $file != &quote;..&quote;) { // for some reason, this has no affect.

            echo &quote;
                  &lt;tr&gt;
                     &lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo; $file&lt;/a&gt;&lt;/td&gt;
                  &lt;/tr&gt;&quote;;
         }

      }

      closedir($handle);

   }

?&gt;[/php:1:591f the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks.tputs, "." and ".."

Code: Select all

<?

   $dir = &quote;../files/&quote;;

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo &quote;
                  &lt;tr&gt;
                     &lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amcode that outputs a directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

&lt;?

   $dir = &quote;../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != &quote;.&quote; || $file != &quote;..&quote;) { // for some reason, this has no affect.

            echo "
                  &lt;tr&gt;
                     &lt;td&gt;<a href=\"$dir"."$file\">&nbsp;&raquo; $file</a>&ammp;quote;." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks.tory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks. if($file != "." || $file != "..") { // for some reason, this has no affect.

echo "
<tr>
<td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
</tr>";
}

}

closedir($handle);

}

?>

This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks.

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still ousome trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
&ato configure this code that outputs a directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks.m having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of tes/";

if($handle = opendir($dir)) {

while(false !== ($file = readdir($handle))) {

if($file != "." || $file != "..") { // for some reason, this has no affect.

echo "
<tr>
<td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
</tr>";
}

}

closedir($handle);

}

?>

This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks.to configure this code that outputs a directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != &quote;.&quote; || $file != &quote;..&quote;) { // for some reason, this has no affect.

            echo &quote;
                  &lt;tr&gt;
                     &lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;>&nbsp;&raquo; $file&amutputs a directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/&quote;;

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != &quote;.&quote; || $file != &quote;..&quote;) { // for some reason, this has no affect.

            echo &quote;
                  &lt;tr&gt;
                     &lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo; $file&lt;/a&gt;&lt;/td&gt;
                  &lt;/tr&gt;&quote;;
         }

      }

      closedir($handle);

   }

?&gt;
This still outputs:

>> .
>> ..
>> file01.jpg
the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>> filerst lines it outputs, "." and ".."

Code: Select all

&lt;?

   $dir = &quote;../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != &quote;.&quote; || $file != &quote;..&quote;) { // for some reason, this has no affect.

            echo &quote;
                  &lt;tr&gt;
                     &lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo; $file&lt;/a&gt;&lt;/td&gt;
                  &lt;/tr&ato configure this code that outputs a directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != &quote;.&quote; || $file != &quote;..&quote;) { // for some reason, this has no affect.

            echo &quote;
                  &lt;tr&gt;
                     &lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo; $file&lt;/a&gt;&lt;/td&gt;
                  &lt;/tr&gt;&quote;;
         }

      }

      closedir($handle);

   }

?&gt;
This still outputs:

>> .
>> ..
>> file01.jpg
&amp

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks.($dir)) {

while(false !== ($file = readdir($handle))) {

if($file != "." || $file != "..") { // for some reason, this has no affect.

echo "
&lt;tr&gt;
&lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo; $file&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;&quote;;
}

}

closedir($handle);

}

?&gt;

This still outputs:

>> .
>> ..
>> file01.jpg
>> fifor some reason, this has no affect.

echo "
<tr>
<td><a href=\"$dir"."$ctory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks.;

if($handle = opendir($dir)) {

while(false !== ($file = readdir($handle))) {

if($file != &quote;.&quote; || $file != &quote;..&quote;) { // for some reason, this has no affect.

echo &quote;
&lt;tr&gt;
&lt;td&gt;&lt;a href=\&quote;$dir&quote;.&quote;$file\&quote;&gt;&amp;nbsp;&amp;raquo; $file&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;&quote;;
}

}

closedir($handle);

}

?puts a directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks.s, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>&outputs a directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and to configure this code that outputs a directory.
But I'm having some trouble getting rid of the two first lines it outputs, "." and ".."

Code: Select all

<?

   $dir = "../files/";

   if($handle = opendir($dir)) {

      while(false !== ($file = readdir($handle))) {

         if($file != "." || $file != "..") { // for some reason, this has no affect.

            echo "
                  <tr>
                     <td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
                  </tr>";
         }

      }

      closedir($handle);

   }

?>
This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks.te;;

if($handle = opendir($dir)) {

while(false !== ($file = readdir($handle))) {

if($file != "." || $file != "..") { // for some reason, this has no affect.

echo "
<tr>
<td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
</tr>";
}

}

closedir($handle);

}

?>

This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks.e(false !== ($file = readdir($handle))) {

if($file != "." || $file != "..") { // for some reason, this has no affect.

echo "
<tr>
<td><a href=\"$dir".&quote;$file\&quote;&am<?

$dir = "../files/";

if($handle = opendir($dir)) {

while(false !== ($file = readdir($handle))) {

if($file != "." || $file != "..") { // for some reason, this has no affect.

echo "
<tr>
<td><a href=\"$dir"."$file\">&nbsp;&raquo; $file</a></td>
</tr>";
}

}

closedir($handle);

}

?>

This still outputs:

>> .
>> ..
>> file01.jpg
>> file02.exe

Any suggestions on how to fix this? getting rid of the "." and ".."?

Thanks.
smo
Forum Newbie
Posts: 20
Joined: Tue May 31, 2005 11:02 pm

Post by smo »

Replace || with and inside the if condition.
HxJ
Forum Newbie
Posts: 2
Joined: Tue Jul 05, 2005 11:54 pm

Post by HxJ »

Thank you so much! :D

Love
Post Reply