Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Member webmastercorey's Avatar
    Join Date
    Nov 2005
    Location
    Kansas
    Posts
    49
    Member #
    11909
    I need a script that sorts a directory into a table. I have made two scripts but I really need a combination of them both. The first script sorts my directory into a table by first reading the file name. It reads the file name and when it comes to a "|" it places information into a cell and then makes a new cell and adds the next set of data.

    So I need a script that sorts my mp3s alphabetically into a table but also "explodes" the data within the file name and places the data into separate cells into a table.



    It's prob easier if you see it:
    Scipt that explodes data and sorts it into a table"

    Code:
    <html>
    
    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>phpsermon</title>
    <style>
    <!--
    body         { color: #FFFFFF; font-family: Georgia }
    .style1 {font-weight: bold}
    a:active     { color: #FFFFFF; text-decoration:underline }
    a:hover      { color: #FFFFFF; text-decoration: underline }
    a            { text-decoration: underline; color: #003366 }
    -->
    </style>
    </head>
    
    <body bgcolor="336699">
    <?php
    ini_set ('display_errors', '0');
    ini_set ('register_globals', '1'); 
    
    $i = 0;
    
    $current_dir = "./mp3/";
    $dir = opendir($current_dir);
    while( $file = readdir($dir) )
    { 
         //exclude all items that you don't want to display
        if( ($file=='.')
            ||($file=='..')
            ||($file=='_vti_cnf')
            ||($file=='service_a.mp3')
            ||($file=='service_b.mp3')
        ) continue;
    
        
    }
    closedir($dir); 
    
    // Sort by 'dt'
    array_multisort( $dt, SORT_DESC, $arr );
    
    echo "<table border=\"0\" align=\"center\">";
    
    foreach ($arr as $val)
    {
        $pieces = explode("|", "$val");
        echo "<tr><td width=\"425\"><a href=\"/mp3/$val\">$pieces[0]</a><br>"; 
        echo "<td width=\"100\" align=\"center\">$pieces[1]";
        echo "<td width=\"100\" align=\"right\">$pieces[2]</tr>";
    }
    echo "</table>";
    ?> 
    </body>
    
    </html>
    
    
    
    
    
    
    and the second script that just sorts alphabetically
    
    
     <?
               if ($dir = @opendir("mp3")) 
               {
                   while (($file = readdir($dir)) !== false) 
                   {
                          if( ($file=='.')
            ||($file=='..')
            ||($file=='_vti_cnf')
            ||($file=='service_a.mp3')
            ||($file=='service_b.mp3')
        ) continue;
                       {
                           $filelist[] = $file;
                       }
                   } 
                   closedir($dir);
               }
               
                         ?>
    
    <form METHOD="GET" ACTION="URL">
            
               <select name="selected_dir">
               <option value="Select Sermon">[ Select a Sermon ]</option>
               <?php 
               asort($filelist);
               while (list ($key, $val) = each ($filelist)) 
               {
                   echo "<option><a href=\"/mp3/$val\">$val</a></option>";
               }
               ?>
                </select>
                <input type="submit" value="Play" name="B1">
    </form> 
    <a href="http://us2.php.net/readdir" target="blank">http://us2.php.net/readdir</a> <br>
    <a href="http://www.codeproject.com/netcf/PocketStreamer.asp"
        target="blank">http://www.codeproject.com/netcf/PocketStreamer.asp</a>

    I know its a bit confusing but I really hope someone can help me with this!

    Thanks,
    Webmastercorey
    "What good will it be for a man if he gains the whole world, yet forfeits his soul?"
    -Matthew 16:26

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:47 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com