Jump to content

Been to every forum on the internet, no one has a clue. Please help!


ValkR

Recommended Posts

I've got:

/A/index.html

/A/1/index.listing

/A/2/index.listing

/A/3/index.listing

 

In index.html, I've got the following PHP code:

<?php

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

foreach ($files as $file)

  {

  include $file;

  }

?>

 

As you can see, what PHP code does is include()'s all the index.listing files.

 

I then create a clone of the A directory and alter the HTML in the .listing files so can tell the difference between A & B when they render:

/B/index.html

/B/1/index.listing

/B/2/index.listing

/B/3/index.listing

 

The issue I am having is "/B/index.html" is ()including the .listing files from the /A/*/ directory, when it should be including them from the /B/*/ directory.

I can't understand why this is happening and hoping someone could shed some light on the issue?

Link to comment
Share on other sites

No one else pointed out that you are using double wild cards from the root?  You are actualy telling the script to look in every subfolder of / so it's guarenteed to pull A & B, if you run the A script it will also pull in A & B.

You will need to code some conditional logic to determin which you want, or change it to be ./A/*.listing and ./B/*.listing for the appropriate index.php files.

Link to comment
Share on other sites

No one else pointed out that you are using double wild cards from the root?

:D LOL mate, no one has said anything!!

 

You are actualy telling the script to look in every subfolder of / so it's guarenteed to pull A & B

Doesn't the "." infront of the directory state 'from this directory!"? If so, A and B would be a parent directory, so PHP shouldn't even know they exist as the code be executed from within.

 

Not sure if I under stand 100%

You do mate and I see what your doing. Very very very smart!... but it didn't work. :(

 

 

To brief you a little what I am doing.. I am starting an online store website.

A = product category

1 = product

*.listing is a listing file I have made - index.listing.

 

When one visits the product category page, I want it to show all the products, so I have include() all the all the listing files, so it builds a list of available products. The .listing files are just a few lines of HTML - an image and some text with a hyperlink to the products own page, which would be /A/1/index.html.

This ways awesome because it means everything related to the product is in a single directory. I don't like central databases like would be found in MySQL. What this means is all I have to do is drag and drop a directory in or out of the A directory. Eventually I am going to make a payment system... Once payment is confirmed, a little script will run that simply moves the product directory outside my www directory, such as to a directory called /sold. Lets say a customer returns the item, all I have to do is move the product directory back into my WWW directory in the relative product category folder and there you have it. Pretty awesome hey! :)

 

I still face the problem of getting this listing system working though. :S

Link to comment
Share on other sites

When one visits the product category page, I want it to show all the products, so I have include() all the all the listing files, so it builds a list of available products. The .listing files are just a few lines of HTML - an image and some text with a hyperlink to the products own page, which would be /A/1/index.html.

This ways awesome because it means everything related to the product is in a single directory. I don't like central databases like would be found in MySQL. What this means is all I have to do is drag and drop a directory in or out of the A directory. Eventually I am going to make a payment system... Once payment is confirmed, a little script will run that simply moves the product directory outside my www directory, such as to a directory called /sold. Lets say a customer returns the item, all I have to do is move the product directory back into my WWW directory in the relative product category folder and there you have it. Pretty awesome hey! :)

 

Awesome? Not really. This is the exact type of scenario where a database is needed. Replying upon file copy/move procedures to run your site is going to lead to problems. It's understandable if you are perhaps intimidated by databases because you are not familiar or don't have a lot of experience. But, that IS the solution you need.

Link to comment
Share on other sites

Never mind, there was nothing wrong with the code. It was another problem. The code works.

 

I don't know about your code because actually never ran. The product page with all the different categories like A B C D... well, each category was hyperlinking to A, It took me 30 hours to notice that. I am really dissapointed in myself, well, not really. This is my first few days of PHP, I was just so focussed on it, forgot I can still make mistakes in HTML.

 

Thanks for your help mate, your help has not gone in vein, believe me! :)

 

 

You are right about the whole point of database, but I do like my setup better and even if I didn't I would stick with it because I don't have time to learn one.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.