...

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



Kolusion
08-21-2011, 11:48 AM
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, 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:

include('./*/index.listing');

Does anyone know how can be done?

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

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

Kolusion
08-21-2011, 02:55 PM
OMG dude! THANK YOU SO MUCH!

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum