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

    Feb 26, 2008
    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.
  2. earnjam macrumors 6502a


    Jun 7, 2007
    North Carolina
    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


    Jan 30, 2006
    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.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="" xml:lang="en" lang="en">
            <title>Title of your page</title><!-- Page title -->
            <style type="text/css"><!-- instead of calling a stylesheet call in a database funtion -->
    // 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'];
            <!-- stuff here -->    
  4. macsrules thread starter macrumors regular

    Feb 26, 2008
    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


    Oct 25, 2007
    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