Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Banned
    Join Date
    Aug 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Making a simple list with a pseudo-database

    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:
    Code:
    include('./*/index.listing');
    Does anyone know how can be done?
    Last edited by Kolusion; 08-21-2011 at 12:51 PM.

  • #2
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    PHP Code:
    $files glob'./*/index.listing' );

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


  • Users who have thanked kbluhm for this post:

    Kolusion (08-21-2011)

  • #3
    Banned
    Join Date
    Aug 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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!

  • #4
    Banned
    Join Date
    Aug 2011
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Never mind, there was nothing wrong with the code. It was another problem. The code works. Thanks again!
    Last edited by Kolusion; 08-22-2011 at 07:12 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •