Search code examples
phpcsshref

CSS href on database mysql through PHP


A noob question, :) I will create a number of css and I would like the css href to be on the database . so that when a specific user will log in, the href tag on the database will be called by PHP and load.

<link href="styles/admin.css" rel="stylesheet" type="text/css"/>

Is it possible? for example:

mysqli database
username : Admin cssstyle : admin.css
username : John  cssstyle : user.css

Solution

  • <?php $result['username']='Admin';
    if($result['username']=='Admin')
    $cssPath='styles/admin.css';
    else
    $cssPath='styles/user.css';
    ?>
    <link href="<?php echo $cssPath;?>" rel="stylesheet" type="text/css"/>
    

    where the $result is database result array obtain from database