Only show directories that have name of date entered by user

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
KellyKitty
Forum Newbie
Posts: 1
Joined: Wed Jan 27, 2010 2:59 am

Only show directories that have name of date entered by user

Post by KellyKitty »

Hello! I'm kind of a PHP rookie but I know I have to do something somewhat challenging...I'd be really thankful for any help :)

I have a directory that will show a list of directories that will be named by year/month/day/ like this:
2009_05_15
2009_05_16
2009_05_17
2009_05_18
2009_05_19
2009_05_20

So theoretically from my website the user will enter in the fields the Year, Month, and day (and maybe hour) that they want so they can download the files that are within that directory(Y/M/D named).

So how can I display only the directories from the date the user entered?

So far I'm only able to download the files once I'm in the directory :

Code: Select all

 
<?php
    if ($dir_handle = opendir(".")) {
        while (($curr = readdir($dir_handle)) !== false) {
                                           //!== is not a typo <!-- s:) --><img src=\"{SMILIES_PATH}/icon_smile.gif\" alt=\":)\" title=\"Smile\" /><!-- s:) -->
      ?>
      <a href="<?=$curr ?>"><?=$curr ?></a> <br></br>    //(<?=$curr ?>) is short for <?php echo $curr; ?>
      <?php
        } //end while
      } //end if
      ?>
 
Is this do-able?
Last edited by KellyKitty on Wed Jan 27, 2010 5:45 pm, edited 1 time in total.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Only show directories that have name of date entered by user

Post by VladSun »

Please, use [syntax=php]your code here[/syntax]

Take a look at http://php.net/manual/en/function.glob.php
There are 10 types of people in this world, those who understand binary and those who don't
Post Reply