Script?

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Arctic
-


Joined: 24 Sep 2004
Posts: 560

PostPosted: Tue Feb 22, 2005 10:12 pm    Post subject: Script? Reply with quote

This one is complicated I think

Can anyone make me a script that displays the content of a whole folders .txt files? So like the stuff in the txt file. With some sort of seperating thing in between to symbolize that it's a different file. Thanks!
Back to top View user's profile Send private message ICQ Number
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed Feb 23, 2005 12:26 am    Post subject: Re: Script? Reply with quote

Code:


<HTML>
<HEAD>
<TITLE>Listing</TITLE>
</HEAD>
<BODY>
<?php

    /* $path should be "." if you want to process the diretcory where */
    /* the script is located */

   $path=".";
   $i = 0;
   $dir = opendir($path);

   while($file=readdir($dir))
   {
     if (is_readable($path . "\\". $file) && ereg(".\.txt", $file))
     {
        echo "<H1>$file</H1><FONT COLOR=" . ($i%2==0?"blue":"red") . "><PRE>";
       
        $fd = fopen ($path . "\\". $file, "r");

        while(!feof($fd))
           echo htmlentities(fread($fd, 4096));

        fclose($fd);

        echo "</FONT></PRE>";
   
   $i++;
      }
   }

   closedir($dir);
?>
</BODY>
</HTML>



PHP is nice. Isn't it? :-)
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Arctic
-


Joined: 24 Sep 2004
Posts: 560

PostPosted: Wed Feb 23, 2005 12:44 am    Post subject: Reply with quote

Can you suggest something that will limit the width the text file take up?
Back to top View user's profile Send private message ICQ Number
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Thu Feb 24, 2005 1:33 am    Post subject: Reply with quote

glyde51 wrote:
Can you suggest something that will limit the width the text file take up?

You can limit the width by applying a style to the HTML elements. Use CSS for a better formatting of the output.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Arctic
-


Joined: 24 Sep 2004
Posts: 560

PostPosted: Thu Feb 24, 2005 2:02 am    Post subject: Reply with quote

http://www.trielite.net/glydeblog/data

I tried to use tables, but I can't get it to work, I also tried putting some CSS tags just outside the PHP, but that didn't work either. Any ideas?
Back to top View user's profile Send private message ICQ Number
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group