title: How to change css background color dynamically in php using color from database
body: <p>I have a grid of items with all their data stored in a database, but I want each of their hover overlays to be the color associated with that item in the database.</p>
  
  <p>Using a color picker (jscolor) during the upload process, the hex code is stored in the database. I can then get the hex code but cannot figure out a way of dynamically styling the background-color of the overlay in php.</p>
  
  <p>This is sort of what I'm trying to achieve:</p>
  
  <p><a href="http://jsfiddle.net/so7vzg4e/" rel="nofollow">Color Overlay</a></p>
  
  <p>CSS</p>
  
  <pre><code>.overlay-custom {
  position: absolute;
  width: 250px;
  height: 250px;
  opacity: 0;
  filter: alpha(opacity=0);
  -webkit-transition-duration: 0.8s;
  -moz-transition-duration: 0.8s;
  -ms-transition-duration: 0.8s;
  -o-transition-duration: 0.8s;
  transition-duration: 0.8s;
  -webkit-transition-property: opacity;
  -moz-transition-property: opacity;
  -ms-transition-property: opacity;
  -o-transition-property: opacity;
  transition-property: opacity;
    background-color:#00ff00;
    z-index:2;
  </code></pre>
  
  <p>I want to dynamically replace the background-color of this div class with the hex code from the database.</p>