stualk Posted March 14, 2011 Share Posted March 14, 2011 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 ""; } Quote Link to comment https://forums.phpfreaks.com/topic/230592-checking-folders-exists/ Share on other sites More sharing options...
HuggieBear Posted March 14, 2011 Share Posted March 14, 2011 Hey Stu, you still hanging around on here. You could take a look at the is_dir() Rich Quote Link to comment https://forums.phpfreaks.com/topic/230592-checking-folders-exists/#findComment-1187318 Share on other sites More sharing options...
stualk Posted March 14, 2011 Author Share Posted March 14, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/230592-checking-folders-exists/#findComment-1187342 Share on other sites More sharing options...
HuggieBear Posted March 14, 2011 Share Posted March 14, 2011 I'm well thanks, if you don't get any joy after reading that then just shout. Quote Link to comment https://forums.phpfreaks.com/topic/230592-checking-folders-exists/#findComment-1187344 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.