I need to generate a tree-like directories from my database. Instead of creating manually 100s of directories, how can I do this automatically? Example: state = 50, the script will create 50 directories city =250, the script will create 250 directories I've read about mod_rewrite but don't understand much. Thanks for your help. Ed PS This is for a non-profit poverty relief organization in Peru.
mod_rewrite would be for if you don't want to create these directories at all and instead give the illusion that the data is coming from this sort of tree structure. For example, if you want your visitors from rochester, ny to go to a url that looks like: http://www.mysite.com/ny/rochester and be given a custom page based on what is in your database in the city_info_table where the state='ny' and the city='rochester' you could have a php script to fetch this info (test.php) that looks like this: <? $city = $_GET['city']; $state = $_GET['state']; $query = "SELECT * FROM city_info_table WHERE state='" . $state . "' AND city='" . $city . "'"; // ..some code to process this query and print results.. ?> PHP: and your .htaccess file to do the mod_rewrite could look something like: RewriteEngine on RewriteRule relief/(.+)/(.+)$ test.php?state=$1&city=$2 [nc] Code (markup): This would rewrite: http://www.mysite.com/ny/rochester to be: http://www.mysite.com/test.php?state=ny&city=rochester and the query in test.php would wind up being: SELECT * FROM city_info_table WHERE state='ny' AND city='rochester' Code (markup): But your visitors would only need to know the easy to remember tree-like url. Hopefully this helps!