Jump to content

Checking folders exists


stualk

Recommended Posts

Hi folks,

 

Working on something and I'm not sure how best to do it. It's a system whereby customers can login and see pdf files. Each customer has a unique reference number which is mirrored with a folder on the server, the folder name being the customer reference number. That's the first bit of checking. Then, within that customer folder there will be between 1 and X sub folders which are labelled by unique product reference numbers. Beyond that, each of the product reference folders will have a year folder with a folder for each month of the year going forward. Here's an example of the folder structure:

 

- Customer Number (e.g. 12345678)

  - Product Number (e.g. 456789) (could be more than one)

    - Year (e.g. 2011) (could be more than one)

      -Month (e.g. 01/02/03/04/05/06 etc)

 

Essentially, I'm just unsure how to check if folders exist and display their contents if they do.

 

Here's my code so far, which does the first part of checking to see if the product numbers exist, but not the folder checking (I've not activated the hyperlinks in this code yet). This doesn't go as far as years and months yet, just the product number:

 

$query = mysql_query("SELECT * FROM customers where id = '$id'");
while($rst = mysql_fetch_array($query)) 

{ echo "$rst[company_name]"; }

$query = mysql_query("SELECT * FROM sites where company_name = '$company'");
while($rst = mysql_fetch_array($query)) 

{ echo "$rst[site]<br>";

if ($rst[product1] !== ""){
echo "- <a href='#'>$rst[product1]</a><br>";
}

if ($rst[product1] == ""){
echo "";
}

if ($rst[product2] !== ""){
echo "- <a href='#'>$rst[product2]</a><br>";
}

if ($rst[product2] == ""){
echo "";
}

if ($rst[product3] !== ""){
echo "- <a href='#'>$rst[product3]</a><br>";
}

if ($rst[product3] == ""){
echo "";
}

if ($rst[product4] !== ""){
echo "- <a href='#'>$rst[product4]</a><br>";
}

if ($rst[product4] == ""){
echo "";
}

if ($rst[product5] !== ""){
echo "- <a href='#'>$rst[product5]</a><br>";
}

if ($rst[product5] == ""){
echo "";
}

 

Link to comment
Share on other sites

Hello mate,

 

Long time, no speak. Hope you're well.

 

Thanks for the URL. I'm taking a look now. I'm 75% there with this and, while I've always been ok reading files from folders in php, reading folders and sub folder that are randomly added to the hosting space isn't something I've ever done before.

 

Will let you know how I get on.

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.