Oct 17, 2013 06:29 AM
(This post was last modified: Oct 17, 2013 06:38 AM by BrainDeadGenius.)
I'm trying to make a mostly automated process.
So, that means making a PHP page from a template.
I've found out that it can create PHP pages using the function I have shown below, but with the template, it does not work.
(The variables at the top are just substitutes for values that would be gathered from the site)
So, that means making a PHP page from a template.
I've found out that it can create PHP pages using the function I have shown below, but with the template, it does not work.
(The variables at the top are just substitutes for values that would be gathered from the site)
PHP Code
<?php
$name = "math";
$category = "test";
$file = "/learn/math/test.php";
$handle = fopen($file, 'w');
$template = " $mysqli = my information
if (mysqli_connect_errno()) {
printf(\"Contact the web administrator; there was a MySQLi connection failure: <br />\" . mysqli_connect_error());
exit;
}
$topics = $mysqli->query(\"SELECT * FROM `" . $name . "` WHERE `category` = '" . $category . "'\");
if (!$topics) {
echo $mysqli->error;
exit;
}
$rows = $topics->num_rows;
echo \"<p>\";
for ( $i = 0; $i < $rows; $i++ ) {
$info = $topics->fetch_array();
echo \"Category: \" . $info['category'] . \" -> <a href='http://www.mysticdev.com/learn/\" . $info['topic_name'] . \"/\" . $info['category'] . \"/\" . $info['filename'] . \"' title='\" . $title . \"'>\" . $info['title'] . \"</a> by: \" . $info['author'] . \" was created at \" . $info['date'] . \"<br />
Preview: \" . $info['preview'] . \"<br /><br />\";
}
echo \"</p>\";
mysqli_close($mysqli);";
fwrite($handle, $template);
fclose($handle);



