Template system in Php/or Mysql

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

nick-8318

Established Member
Impact
23
Is it better to have a template system in the database or in a template file.

Example 1:

template_forums.php:
$forum_top = "<table><tr><td>{forum_name}</td></tr>";

and then on forums.php:
include("templates/default/template_forums.php");
$body = str_replace("{forum_name}", $forum_name);
echo $body;


or this method

a row in mysql db:
forum_top TEXT "<table><tr><td>{forum_name}</td></tr>"

and then in forums.php:
$result = query("SELECT forum_top FROM templates WHERE styleid='1'");
$row = mysql_fetch_array($result);
$body = str_replace("{forum_name}", $row[forum_top]);
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
i would say the config file it would be alot quicker and save on system resources.
also to save a few more resources on your system you can speed up your code a hole lot more. since there really isnt any need for the str_replace function in your code youve posted


and then on forums.php:
include("templates/default/template_forums.php");
$forum_top = "<table><tr><td>". $forum_name . "</td></tr>";
echo $forum_top;

will work just as well and just as faster.
 
0
•••
Dynadot — .com TransferDynadot — .com Transfer
Appraise.net

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back