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 4 of 4
  1. #1
    Member webmastercorey's Avatar
    Join Date
    Nov 2005
    Location
    Kansas
    Posts
    49
    Member #
    11909
    Question: HOW DO I GET THIS SCRIPT TO WORK INSIDE A HTML DOCUMENT?

    $dir = opendir("./sounds");
    print "<ul>\n";
    while($file = readdir($dir)) {
    if (!preg_match("/^\..*$/", $file)) {
    print " <li><a href='/sounds/$file'>$file</a>\n";
    }
    }
    }
    print "</ul>\n";
    closedir($dir);
    "What good will it be for a man if he gains the whole world, yet forfeits his soul?"
    -Matthew 16:26

  2.  

  3. #2
    Junior Member
    Join Date
    Nov 2005
    Posts
    19
    Member #
    11796
    You should only have to change the part that says "PATH TO YOUR DIR". I don't think you need to fill in <a href>. I didn't fill it in and it works. If you want hard returns, instead of the links appearing horizontally, place <br> at the end of the </a> tag.

    Code:
    <?php
    ini_set ('display_errors', '0');
    ini_set ('register_globals', '1'); 
    
    
    $current_dir = "PATH TO YOUR DIR"; 
    
    
    
    
    echo $current_dir ."<br>" ; 
    $dir = opendir($current_dir); 
    while($file = readdir($dir)) 
    { 
    if(($file=='.')||($file=='..')) continue; 
    echo "<a href=\"$file\">$file</a>"; 
    } 
    closedir($dir); 
    ?>

    Website Design & Hosting by E-Office Professionals www.eofficeprofessionals.com

    The only stupid question is the one not asked.


    Offer solutions-not criticism.

  4. #3
    Member webmastercorey's Avatar
    Join Date
    Nov 2005
    Location
    Kansas
    Posts
    49
    Member #
    11909
    Do I just insert that into the document or is there some configuration or tags that I have to add?
    "What good will it be for a man if he gains the whole world, yet forfeits his soul?"
    -Matthew 16:26

  5. #4
    Junior Member
    Join Date
    Nov 2005
    Posts
    19
    Member #
    11796
    Quote Originally Posted by webmastercorey
    Do I just insert that into the document or is there some configuration or tags that I have to add?
    I'm sorry. I haven't coded in php in about a year. I've tested this code, though and it works. Just copy/paste. However, I'm sure that this must not be the best way to write your code. I guess you should write your text in php if you want, instead of just opening and closing php tags like I am doing. The text in red is where 1-you change your directory path and 2-I have added breaks. The text in blue, you need to contact your host to see if this is required-my php script will not function without it.

    Code:
    Type any text here.<Br><BR>
    <?php
    ini_set ('display_errors', '0');
    ini_set ('register_globals', '1'); 
    
    
    
    
    $current_dir = "YOUR DIR PATH GOES HERE"; 
    
    
    
    
    $dir = opendir($current_dir); 
    while($file = readdir($dir)) 
    { 
    if(($file=='.')||($file=='..')) continue; 
    echo "<a href=\"$file\">$file</a><BR><BR>"; 
    } 
    closedir($dir); 
    ?>

    Website Design & Hosting by E-Office Professionals www.eofficeprofessionals.com

    The only stupid question is the one not asked.


    Offer solutions-not criticism.


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 09:33 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com