View Full Version : Most Efficient Way to make a Custom Templated Site?

03-04-2010, 03:19 PM
Say I have a website that allows the user to select a specific template design to display the site. The user's template design preference is saved in a mySQL database (user registration required).

What is the most efficient way to display the webpage template? (ie. lowest load)

$sql="SELECT customTemplate FROM userPrefs WHERE userid = {$_SESSION[userid]}";
$userTemplate = mysql_result($result,0,0);
include($userTemplate . ".php");

Is this the best way to do it? Is there another way (excluding cookies since I want to make it user registration based).

03-04-2010, 03:59 PM
That seems like an OK way to me...nothing overwhelming about a SQL query.

The only thing I would do is grab all of the user settings when the user logs in...you've got to do a query anyways, so why not just grab all the settings and store them in the session the first time?