Apply background-color to Input with hexadecimal number stored in database

0

I comment, in my DB I have a table Categorias which contains, CategoriaID , CategoriaDescription and CategoriaColor , my question is, when displaying the different categories in example inputs

 <input type="button" value="'$row['CategoryDescription']'">

How can I give each one the background color with which the registration was made?

    
asked by Oscar Valentin Hernandez Marti 07.08.2018 в 19:28
source

2 answers

2

Do not put the property in "value", put it in style. Example

<input type="button" style="background-color:<?php $row['CategoryDescription'] ?>">

    
answered by 07.08.2018 / 20:13
source
1

when you are printing it you can put it like that

<input type="button" value="'.$row['CategoryDescription'].'" style="background:#'.$row['CategoriaColor'].'">

only if the color comes as hexadecimal example 889900

    
answered by 07.08.2018 в 20:07