Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

  1.  permalink
    I have to change the value of a class defined in CSS depending upon user selection.
    For eg. There is a color picker to change color of a <tr>. The color chosen by user gets stored in database. Now i need to retrieve the color code from the Database and modify the class value in CSS file.
  2.  permalink
    If anyone has solution for it Can u please email me on the same on following email id : mehul_19851@rediffmail.com
    •  
      CommentAuthornifkin
    • CommentTimeDec 19th 2005
     permalink
    Use a PHP script (or whatever server-side language you're using) to generate your CSS dynamically so it can retrieve data like that from the database.
    • CommentAuthorSam K
    • CommentTimeDec 19th 2005 edited
     permalink
    <?php
    header('Content-type: text/css');

    $db = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    mysql_select_db('database_name',$db);

    $user = "username";
    $sql = "SELECT css FROM foo WHERE user=$user";
    $result = mysql_query($sql)
    or die(mysql_error());
    $row = mysql_fetch_row($result);
    $colour = $row[0];
    ?>

    tr {
    color: <?=$colour; ?>;
    }
    Save that as style.php (or whatever), and include it into your document as you would for a normal CSS file.
    I'm tired so there's probably a bug in that script somewhere. But that should give you a start.
Add your comments
    Username Password
  • Format comments as (Help)