Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    417
    Thanks
    168
    Thanked 1 Time in 1 Post

    Thumbs up Most Efficient Way to make a Custom Templated Site?

    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)

    Code:
    <?php
    if(isset($_SESSION["userid"])){
     $sql="SELECT customTemplate FROM userPrefs WHERE userid = {$_SESSION[userid]}";
     $result=mysql_query($sql);
     if($result){
       $userTemplate = mysql_result($result,0,0);
       include($userTemplate . ".php");
     }
    }else{
     include("defaultTemplate.php");
    }
    ?>
    Is this the best way to do it? Is there another way (excluding cookies since I want to make it user registration based).
    Last edited by Bobafart; 03-04-2010 at 03:24 PM.

  • #2
    Regular Coder bacterozoid's Avatar
    Join Date
    Jun 2002
    Location
    USA
    Posts
    490
    Thanks
    24
    Thanked 35 Times in 35 Posts
    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?

  • Users who have thanked bacterozoid for this post:

    Bobafart (03-05-2010)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •