Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Background color from table column

Tags:

css

php

mysql

I have a hex color set inside of a table column and trying to set it to a div background but it will not apply it:

<?php
$user = $_SESSION['user'];
    try{
        $results = $dbh->query("SELECT *
                                FROM cat_List
                                INNER JOIN user_cat_link_table
                                ON cat_List.Cat_ID = user_cat_link_table.Cat_ID
                                WHERE user_cat_link_table.UserID = $user");

}catch(Exception $e) {
    echo $e->getMessage();
    die();
}

$docs = $results->fetchAll(PDO::FETCH_ASSOC);

foreach($docs as $docs){  

echo '
    <a href="catView.php?cat_id='.$docs["cat_id"].'">
        <div class="indexBox" style="background-color="'.$docs["cat_color"].'">
            <div class="indexBoxHeader">
                <i class="fa fa-users" style="font-size: 2em;"></i></div>
            <div class="indexBoxFooter">
                <p>'.$docs["cat_title"].'</p>
            </div>
        </div>
    </a>
    ';}
?>

If I echo the cat_color out it return the value #000 which is the value in the table? Is my syntax wrong?

like image 739
PhpDude Avatar asked Mar 15 '23 23:03

PhpDude


1 Answers

It should be style="background-color:'.$docs["cat_color"].'"

like image 126
Alon Eitan Avatar answered Mar 19 '23 08:03

Alon Eitan