I have the database in MySql as well as we wish to keep the same webpage blueprint for any page, so we wish make use of the database to reinstate the "placeholders" in php. How do we do this? Can somebody yield the walkthrough?
I have the database in MySql as well as we wish to keep the same webpage blueprint for any page, so we wish make use of the database to reinstate the "placeholders" in php. How do we do this? Can somebody yield the walkthrough?
If you have a table of CMS elements, fields "name, value" with values such as "site_name, My Awesome Site", I suggest:
$a = mysql_query(‘SELECT * FROM elems’);
while($b = mysql_fetch_assoc($a)) {
$f[] = "pattern_start".$b['name']."pattern_end";
$r[] = $b['value'];
}
$d = file_get_contents(‘your_template.html");
$d = preg_replace($f, $r, $d);
echo $d;
I’m not sure what format your placeholders are in, but you’ll need to change the pattern bit. See php.net/pref_replace for details.