Making a simple list with a pseudo-database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Kolusion
Forum Newbie
Posts: 2
Joined: Sun Aug 21, 2011 5:16 am

Making a simple list with a pseudo-database

Post 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?
Kolusion
Forum Newbie
Posts: 2
Joined: Sun Aug 21, 2011 5:16 am

Re: Making a simple list with a pseudo-database

Post 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.
Post Reply