I use PHP to query CSS settings from a MySQL database, which is then reflected in the CSS stylesheet. Example snippet below:
<?php
$connect =
$query = ($connect, "SELECT bgcolor, font FROM displays WHERE name = 'mySettings'");
while ($row = mysqli_query($query)){
$bgcolor = $row[bgcolor];
$font = $row[font];
}
echo '
body {
background-color: #'.$bgcolor.';
font: '.$font.';
}
';
?>
The “displays” table has one column for each CSS property set. Each line represents a set of color / font / padding / margin settings saved by the user.
The font column is the varchar (50) data type. What data type should be "bgcolor"? CSS wants to see a hexadecimal value, but MySQL does not have a hexadecimal data type. A logical choice would be to save the value as an int type and use the HEX () function in the SELECT statement.
, , / , char (6)? PHP , . , ; CSS.
, int char?