Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7164401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:04:09+00:00 2026-05-28T14:04:09+00:00

I have several variables (hex colors) defined in a database. I need to pass

  • 0

I have several variables (hex colors) defined in a database. I need to pass these variables from MySQL to a LESS.js stylesheet via PHP. Possible?

If not, any advice on a way to do something similar? The lighten and darken variables are key.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:04:10+00:00Added an answer on May 28, 2026 at 2:04 pm

    The best approach that come in my mind is to dynamic generate a LESS file using PHP (including your vars).

    1\ You will need to include a new style sheet in your HTML pages.

    <link rel='stylesheet/less' href='css/style.php' />
    

    2\ In your style.php include your PHP vars as follows:

    <?php header("Content-type: text/css; charset: UTF-8"); ?>
    
    @brand_color_1 = <?php echo $brand_color_1; ?>;
    /* Add all other vars do you need. */
    

    3\ Then at the bottom (or after you LESS var declaration) of this style.php add all your needed imports as follows:

    <?php
      header("Content-type: text/css; charset: UTF-8");
    
      @brand_color_1 = <?php echo $brand_color_1; ?>;
      /* Add all other vars do you need. */
    
      @import "style.less";
    ?>
    

    This will works like a clock.

    There is an article you can read about CSS Variables with PHP written by Chris Coyier.


    Another not recommended alternative is compiling you LESS files in client-side, you could manually compile them and pass PHP vars doing the following:

    <script type="text/javascript">
    var colors = '';
    colors += '@brand_color_1: <?php echo $brand_color_1 ?>;'
    colors += '@brand_color_2: <?php echo $brand_color_2 ?>;'
    colors += '@import "style.less"';
    // Add other imports.
    var parser = new (less.Parser)();
    parser.parse(colors, function(err, tree) { 
      var css = tree.toCSS();
      // Add it to the DOM maybe via jQuery
    });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several variables that I need to send from page to page... What
I have several variables like these: $foo = '123'; $bar = 'bqwe'; I need
I need to have several instances of a union as class variables, so how
I have several variables coming from an array in $POST_['array'] i wish to make
I have several buttons that set some variables for another class (via extern). Thing
I have several $_POST variables, they are $_POST['item_number1'] $_POST['item_number2'] and so on I need
I'm running into a I18N-problem here. I have a database with several variables stored.
I have several variables in an SSIS package that I would like inserting into
I have several tables/variables (sampled below): mytable = { ['100'] = { ['2']=0,['3']=0,['5']=0,['6']=0,['7']=0,['9']=0}, ['101']
My User entity class have several member variables (e.g. String firstName) which are persisted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.