I am trying to create a bunch of static HTML pages from a single PHP template. I want to pass an array (a row in a MySql DB) to the .php template file, so that I can use the contents as variables and get the HTML page back. What's the best way to do this? A POST request? A function? I loop through the MySQL query results in the following code and create an .html page for every row, but I'm not sure how to pass the $row array to the 'Template.php' file:
while ($row = mysql_fetch_array($result))
{
$variableToPass = $row;
$dynamicsource = fopen('Template.php', 'r');
$htmldata = fread($dynamicsource, 1235);
fclose($dynamicsource);
$targetfilename = "row/"
. $row['name']
. ".html";
$targetfile = fopen($targetfilename, 'w');
fwrite($targetfile, $htmldata);
}
The Template.php file could look, for example, like:
<html> <body> <?php include 'mySqlTests.php'; print_r($variableToPass); ?> other text and stuff </body> </html>