Page 1 of 1

Making a simple list with a pseudo-database

Posted: Sun Aug 21, 2011 5:47 am
by Kolusion
I am developing a website. I need to create a list for the products I sell.
I will be using pseudo-database and it will work like this.

/index.html
/1/index.listing
/2/index.listing
/3/index.listing

index.html is where the code is executed from.
The numbers are my internal product codes, which I will use as directory names for each product.
index.listing are HTML files containing markup which will have a layout of a thumbnail of the product and some text giving a description of what it is. - similar to eBay's search list result layout.

What I want the code to do is reclusivly include() all of the 'index.listing' files. The result will create a list of products.
I am sure there are other ways to achieve what I want, and this is the way I want to do it.

I am new to PHP and don't know much about "functions and elements". I tried the following code, but it didn't work:

Code: Select all

include('./*/index.listing');
Does anyone know how can be done?

Re: Making a simple list with a pseudo-database

Posted: Sun Aug 21, 2011 9:11 am
by Kolusion
The answer to this question is:

Code: Select all

$files = glob( './*/index.listing' );

foreach ( $files as $file )
{
    include $file;
}  
... which was provided to me by kbluhm from codingforums.com.

Solved.