Can CSS Files be Stored in a SQL database and accessed dynamically.

Discussion in 'Web Design and Development' started by macsrules, Jun 13, 2008.

  1. macsrules macrumors regular

    Joined:
    Feb 26, 2008
    #1
    Hello everyone,


    I am starting a major undertaking. I am rebuilding a companies website but here is where it gets interesting. They want it to be tied to a database which they have people that can write the tags for that. I am building the site though. They want it to have skins of each of their major clients which are around 350 clients. So 350 skins. I am going use CSS style sheets for each of the different skins so that when the client comes to log in, it has the feel and look of their own website.

    1. On the Mast Heads, I am going to put them in a Database. We know our clients names so when they log in we will dynamically be able to change the site header to look like their own site.

    2. Here is my question. Can CSS also be stored in a MYSQL database to be accessed dynamically as images can?


    Thanks in advance for any help.
    Macsrules
     
  2. earnjam macrumors 6502a

    earnjam

    Joined:
    Jun 7, 2007
    Location:
    North Carolina
    #2
    Why not just have a script call a specific CSS file based on the name of the user? (since you're already pulling that data in)
     
  3. Cabbit macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #3
    You can have a if then else kinda set up. But your calling css from the database not a stylesheet this way so it would look like inline styleing.

    PHP:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>
            <title>Title of your page</title><!-- Page title -->
            <style type="text/css"><!-- instead of calling a stylesheet call in a database funtion -->
                <?php
                    
    // Get the client name //
                    
    $client_name $session->clientname;
                    
    // Call up client stylesheet //
                    
    $sql "SELECT `id`, `client_name`, `css` FROM `client_css` WHERE `client_name` = '$client_name' ";
                    
    $result mysql_query($sql) or die("Sorry there seems to be a problem with the database"); 
                    
    // print out the clients css //
                    
    print $result['css'];
                
    ?>
            </style>
        </head>
        <body>
            <!-- stuff here -->    
        </body>
    </html>
     
  4. macsrules thread starter macrumors regular

    Joined:
    Feb 26, 2008
    #4
    I am very green, really new to dynamic development. This is going to be my starting point. Nothing like jumping in head first :).

    Anyway, I thought since there are going to be around 350 different mast heads that it would be easier if it is possible to put the CSS files into the database and use Dreamweaver's dynamic tools to call them based on the ID.

    Again, I am still in the learning process of dynamic development, scratch that, I am just starting to learn.

    The company has 7 PHP developers on staff that are going to be using smarty tags to tie that database to the web pages, I just thought since I am starting to learn how Dreamweaver can tie to SQL DB's on the back-end and access data that is stored dynamically it would be a good idea. I guess I am way off.

    Thanks babyjenniferLB for the reply.
     
  5. notnek macrumors 6502

    notnek

    Joined:
    Oct 25, 2007
    #5
    You could just have inline CSS and have a table in your database with the different options you'll give in your CSS.

    $link_color, $body_background, etc.
     

Share This Page