pass array as parameter to PHP file

Animal

New Member
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:\[code\]while ($row = mysql_fetch_array($result)){ $variableToPass = $row; $dynamicsource = fopen('Template.php', 'r'); $htmldata = http://stackoverflow.com/questions/3690158/fread($dynamicsource, 1235); fclose($dynamicsource); $targetfilename ="row/" . $row['name'] . ".html"; $targetfile = fopen($targetfilename, 'w'); fwrite($targetfile, $htmldata); }\[/code\]The Template.php file could look, for example, like:\[quote\]\[code\] <html> <body> <?php include 'mySqlTests.php'; print_r($variableToPass); ?> other text and stuff </body></html>\[/code\]\[/quote\]
 
Back
Top