Hi guys. I'm looking for a solution to merge a MySQL database with a static file (for example put everything into HTML files) So for example if i have 1000 entries it would use a template i give it and create 1000 files. Is there anything like this available? Thanks.
$result = mysql_query("SELECT * FROM `pages`;"); while($db=mysql_fetch_assoc($result)){ $filename = "pages/" . $db['title'] . ".html"; $fileHandle = fopen($filename ,"w"); fwrite($fileHandle, $db['content']); fclose($fileHandle); } Code (markup): This is assuming that, for example, you are using a table called "pages" with a "title" field and a "content" field. It will make the title the filename, and the content the content of the file. It will create these files in the /pages/ directory.
I understand the code, but it wouldn't help me in the fact that i would need to "merge" this with a predefined template. ... Now that i look at your code it looks extremely simple to include two more files or one and explode it at some character so you'd get a header and a footer too. Thanks so much for the help!