title: Style inside each element in a Foreach PHP
body: <p>I want to make a style in JavaScript for each result in the loop foreach in PHP. If I put the document.id.style.background-color. it just gets all the elements, but I want to style each one of them.</p>
  
  <p>Just to summarize: The Foreach loop is giving me a kind of calendar for each employee, and I just want to print a color for each employee.</p>
  
  <p>This code is from MySQL Database and </p>
  
  <pre><code>            $resultado = $base-&gt;escala_contrato($id_contrato, $mes_ref);
          foreach ($resultado as $row):
  
           $html = date('d/m', strtotime($row['dt_work']))."&lt;br&gt;&lt;br&gt;".$row['nome']."&lt;br&gt;".$status; // get the values from table. cols dt_work and dt_nome
  
                          echo "&lt;script&gt;
  
  
                              document.getElementById('".date('d/m/Y', strtotime($row['dt_work']))."').innerHTML = '".$html."';
  
                          &lt;/script&gt;";
  
                  //echo '&lt;div class="day"&gt;'.$row['name'].'&lt;br&gt;'.date('d/m/Y', strtotime($row['dt_work'])).'&lt;br&gt;'.$status.'&lt;/div&gt;';
          endforeach; // here is where I want the 'magic': this part will repeat with different colors.
  </code></pre>