Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm a little new at this, so sorry

Status
Not open for further replies.

rfrenke

Programmer
Joined
Jun 21, 2003
Messages
9
Location
US
I'm a little new at this, so sorry if the answer should be obvious.
Here's my problem:

I need to create an index page for a directory. The index page needs to contain the following:

a. A list of all of the files within the directory, but only the php files, and only the ones that begin with "PHOTO". For example:

PHOTO1.php
PHOTO2.php
PHOTO3.php
PHOTO4.php
PHOTO5.php

b. I also need it to display the contents of the 13th table cell within each of those pages, because that has a description of the page. Something along the lines of:

Code:
<table> 
<tr><td> $fileName[1] </td><td> $fileDescription[1] </td></tr> 
<tr><td> $fileName[2] </td><td> $fileDescription[2] </td></tr> 
<tr><td> $fileName[3] </td><td> $fileDescription[3] </td></tr> 
<tr><td> $fileName[4] </td><td> $fileDescription[4] </td></tr> 
<tr><td> $fileName[5] </td><td> $fileDescription[5] </td></tr> 
<tr><td> $fileName[6] </td><td> $fileDescription[6] </td></tr> 
<tr><td> $fileName[7] </td><td> $fileDescription[7] </td></tr> 
</table>

I would normally just create a table in a plain HTML page and do this manually, but the are A LOT of these &quot;PHOTO&quot; pages and more with probably be added. I figured that PHP my be the best way to automate the process, but I'm getting a little lost.

I'm assuming I need to build these into arrays but I'm a little lost on the approach.

This is as far as I've been able to get:

[/code]
<?php
$dir = opendir(&quot;.&quot;)
?>
[/code]

After that point I just can't seem to find anything in the books I have that seems to help.
 
here's some code how to retrieve the files:

Code:
<?php 
if ($handle = opendir('.')) {
    while (false !== ($file = readdir($handle))) { 
        if (preg_match(&quot;/PHOTO\d+\.php/i&quot;,$file)) { 
            # print your HTML next
        } 
    }
    closedir($handle); 
}
?>

Look at:
 
ah regular expressions again...

can anyone give me a good tutorial for it? along with good examples...

i have a book in php but it doesnt help much... :(

Known is handfull, Unknown is worldfull
 
PHP and MySQL Web Development by Luke Welling and Laura Thompson


is great book, im currently reading it and learning.

ISBN: 0-672-31784-2

the book store can find the book easyer with that ISBN number.

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top