I am trying to use a form to set colors in a table in my database, then call those colors into my stylesheet (style.php)
Defining the color variables manually works:
<?php
header("Content-type: text/css");
$color1 = '#cc0000';
?>
#thisdiv { background-color: <?php echo $color1; ?>; }
But this does not:
<?php
header("Content-type: text/css");
$getSettings = mysqli_query($db, "SELECT * FROM settings WHERE setting_id = 1");
$setting = mysqli_fetch_assoc($getSettings);
$color1 = $setting['setting_color1'];
?>
#thisdiv { background-color: <?php echo $color1; ?>; }
My 'settings' table looks like this:
setting_id | setting_color1 | setting_color2 | setting_color3
1 | #cc0000 | #000000 | #ffffff
How can I get this working properly? Maybe I am doing something wrong, or maybe I am just overlooking something stupid. Any help is appreciated.
background-color- it's just empty. @YourCommonSense $db connection is defined elsewhere. It was tested and is working properly. I figured that would be assumed, sorry. The query was checked (as per a comment below) and is working also.var_dump($setting)before you echo it and check the values.