View Full Version : Making a simple list with a pseudo-database

08-21-2011, 12:48 PM
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 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, but I want to do it this way.
The benefit of doing it this way is that the website will be highly modular. Once a sale has been made I can simply get php to move the folder of the sold product to a directory outside the websites www, via means such as "mv .../77 /.../sold", and won't have to play around (and learn from scratch) a real database system, such as MySQL.
I am open for opinions.

I am new to PHP and don't know much about "functions and elements".

I tried the following code, but it didn't work:


Does anyone know how can be done?

08-21-2011, 03:34 PM
$files = glob( './*/index.listing' );

foreach ( $files as $file )
include $file;

08-21-2011, 03:55 PM

I have spent the last 6 hours trying to figure this out. Your help really has been appreciated man! :thumbsup:

08-21-2011, 05:50 PM
Never mind, there was nothing wrong with the code. It was another problem. The code works. Thanks again! :)