Any guidance here would be greatly appreciated. I have a MYSQL db table that has everything I want for all of my pages: record1: page1.html ; title1 ; meta1 ; bodycontent1 record2: page2.html ; title2 ; meta2 ; bodycontent2 record3: page3.html ; title3 ; meta3 ; bodycontent3 and so on and so forth. Now, how can I generate all of these pages from a single index.html? I can access the DB and fetch an array to list all of the titles, then assign a variable to all of the pages, so I come up with something like this on index.html: <a href="page1.html">title1</a> <a href="page2.html">title2</a> <a href="page3.html">title3</a> Code (markup): And all of those links work, except that there's no such page as page1.html yet, so I obviously get a 404. So, what do I need to do to get php to generate an html page using the other fields from the record it's currently on? Do I do this in the array itself? Is there a function I'm missing here? Hope that makes sense. Thanks
Uh, no CSS will not create Dynamic content... PHP will, and since you've already got the MySQL setup, I would do something along the lines of: $page = $str_replace(".html", "", $_SERVER['FILENAME']); $query = mysql_fetch_array(mysql_query("SELECT * FROM table WHERE page='$page' LIMIT 1")); extract($query, EXTR_PREFIX_ALL, "page"); PHP: Forgive me if the code above has an error in it, it's a "rough draft" and I'm very tired at the moment, but it should give you an idea of how to go about making it work. (if you don't know what extract does, check this page: http://us.php.net/manual/en/function.extract.php ) Good luck, and if I did make an error, please let me know and I'll fix it up tomorrow when I've had a full night's sleep and my brain works.
If page1.html / page2.html / page3.html don't exist then, if I what I understand you want to do is correct, you first need to redirect these to index.php and then handle the page request. To redirect you will have to use mod_rewrite in a .htaccess file: then the php code would be something like: or, do you want to get php to create static pages from the DB ?