VirtualDN
Since this site was sold, the new owner of VirtualDN has lost interest. But I got a response from him! We're in talks right now.
   Home -> VirtualDN Forums Help Help
Member Login
User:
Pswd:

Navigation
How vDN Works Contact VirtualDN

Announcements
Since this site was sold, the new owner of VirtualDN has lost interest. But I got a response from him! We're in talks right now.


Welcome, Guest. Please login or register.
July 29, 2010, 11:35:50 PM

Login with username, password and session length
Search:     Advanced search
New: WHOIS lookups also display the owner's REAL email address for easy communication outside of vDN if necessary.
10225 Posts in 1271 Topics by 522 Members
Latest Member: Sancho Panza
* Home Help Search Login Register
Currently 0 users are in the Live Chat. (Members only)
VirtualDN Forums  |  Virtual Web Development  |  Programming  |  Topic: PHP 'opendir' 0 Members and 0 Guests are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: PHP 'opendir'  (Read 623 times)
Mikor
Fresh Out of the Fridge
Domain Newcomer
*

Reputation: 9
Offline Offline

Gender: Male
Posts: 491


vDNs Official Satanist


View Profile WWW
PHP 'opendir'
« on: April 20, 2006, 07:56:36 AM »

Here is my code:

<?php
function readdirectory($path)
{
     echo 
"<table width=450 border=1 cellpadding=0 cellspacing=0><tr>";
     if (!
file_exists($path)) echo "not an existing directory";
     if (!
is_dir($path)) echo $path." isnt a directory";
     
     
$main_dir =opendir ($path) or die("Error reading ".$path);
     
$i=0;
     while (
$entry=readdir($main_dir))
     {
           if(
filetype($path."/".$entry)=="file") {
                echo 
"<td>".$entry."</td>";

                echo 
"<td><a href = \"./eBooks/".$_GET['c'].'/'.$entry."\">View</a></td>";

                echo 
"<td>".filesize($path."/".$entry)." bytes</td>";

                echo 
"</tr><tr>";

           }


     }
     echo 
"</tr></td></table>";
}

if(isset(
$_GET['c']) == true){

     
$path="./eBooks/".$_GET['c'];

     echo 
'<b>Browsing Category '.$_GET['c'].': </b><br><br>';
     
readdirectory($path);
}else{

     echo 
'Choose a category:<br>';

     echo 
'<a href = "browse.php?c=Magic">Magical Books</a><br>';

     echo 
'<a href = "browse.php?c=Lovecraft">Books written by Lovecraft (They are a bit random, so they get their own category)</a><br>';
}
?>


How can I make it display the files in alphabetical order? right now they're just displayed in any random order.


EDIT: Replaced <tab>s with <space>s to make it more readable. I also changed the code a bit.
« Last Edit: April 20, 2006, 03:27:16 PM by Mikor » Logged

Mikor
Fresh Out of the Fridge
Domain Newcomer
*

Reputation: 9
Offline Offline

Gender: Male
Posts: 491


vDNs Official Satanist


View Profile WWW
Re: PHP 'opendir'
« Reply #1 on: April 20, 2006, 07:58:03 AM »

Its easier to see for yourself, heres the page:

http://mikor.clearlyhosted.net/eLibrary/browse.php?c=Magic
Logged

P10n33R
Fresh Out of the Fridge
Domain Newcomer
*

Reputation: 4
Offline Offline

Gender: Male
Posts: 151


View Profile WWW
Re: PHP 'opendir'
« Reply #2 on: April 20, 2006, 10:44:07 AM »

Good way to get things done.
Logged
Mikor
Fresh Out of the Fridge
Domain Newcomer
*

Reputation: 9
Offline Offline

Gender: Male
Posts: 491


vDNs Official Satanist


View Profile WWW
Re: PHP 'opendir'
« Reply #3 on: April 20, 2006, 11:08:07 AM »

I was asking how to make the files display in alphabetical order. Did you answer that? no.

lol
« Last Edit: April 20, 2006, 11:17:15 AM by Mikor » Logged

P10n33R
Fresh Out of the Fridge
Domain Newcomer
*

Reputation: 4
Offline Offline

Gender: Male
Posts: 151


View Profile WWW
Re: PHP 'opendir'
« Reply #4 on: April 20, 2006, 11:25:14 AM »

Well, if you talk like that I will not give you an answer.
Logged
Mikor
Fresh Out of the Fridge
Domain Newcomer
*

Reputation: 9
Offline Offline

Gender: Male
Posts: 491


vDNs Official Satanist


View Profile WWW
Re: PHP 'opendir'
« Reply #5 on: April 20, 2006, 11:26:22 AM »

Im annoyed because everything im trying isnt working...
Logged

commes
Global Moderator
VirtualDN Contributor
*****

Reputation: 15
Offline Offline

Gender: Male
Posts: 1,333

This Spot And Avatar Area For Sale


View Profile WWW
Re: PHP 'opendir'
« Reply #6 on: April 20, 2006, 12:05:28 PM »

Good way to get things done.
pioneer did you even read what he said?
Logged

Mikor
Fresh Out of the Fridge
Domain Newcomer
*

Reputation: 9
Offline Offline

Gender: Male
Posts: 491


vDNs Official Satanist


View Profile WWW
Re: PHP 'opendir'
« Reply #7 on: April 20, 2006, 03:28:37 PM »

I dont think he did. I think he's just trying to get lots of posts, he has quite a lot of pointless posts.
Logged

Jakey
Fresh Out of the Fridge
Domain Hobbiest
*

Reputation: 8
Offline Offline

Gender: Male
Posts: 743

Search.com


View Profile WWW
Re: PHP 'opendir'
« Reply #8 on: April 26, 2006, 11:38:01 PM »

Yeah I agree.
Logged

BrandonG
Fresh Out of the Fridge
Domain Hobbiest
*

Reputation: 12
Offline Offline

Gender: Male
Posts: 560

vDN Idiot


View Profile
Re: PHP 'opendir'
« Reply #9 on: April 27, 2006, 06:25:12 PM »

Same thing with Jakey LOL

I do the same, only a little bit though! 
« Last Edit: April 27, 2006, 06:25:33 PM by BrandonG » Logged

compuXP
Administrator
Domain Hobbiest
*****

Reputation: 18
Offline Offline

Gender: Male
Posts: 914


VirtualDN Webmaster


View Profile WWW
Re: PHP 'opendir'
« Reply #10 on: April 30, 2006, 05:37:07 PM »

Actually, I've been wanting to know this for quite some time for users to browse veblo media files (real site) - thanks for this
Logged

NEW: File a TM Request and protect your brand name, slogan, or logo!

Tell everyone on your buddy list, forums, and friends about VirtualDN! The more the merrier, right?
Pages: [1] Go Up Print 
VirtualDN Forums  |  Virtual Web Development  |  Programming  |  Topic: PHP 'opendir' « previous next »
Jump to:  

Powered by MySQL Powered by PHP VirtualDN Forums | Powered by SMF 1.0.7.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!
Page created in 0.048 seconds with 19 queries.