Beste,

Ik heb in mijn php code de volgende style

<style>
td{
color: black;
width: 100px;
background-color: #ceDDce;
height: 50px;
text-align: center;
En dan bij de table:

echo'<td>'.$row['geslacht'].'</td>

Nu zou ik graag een verschillende kleuren willen afgaande op de value van de inhoud van "geslacht", dus meisje = roze , jongen = blauw , onbekend = groen

Is dit mogelijk ?
Allereerst,

De style tekst staat ook in de php pagina onder

<body>
<style>
textarea, input, button,
a, td, span{
font-family: "Trebuchet MS", Helvetica, sans-serif;
}

td{
color: black;
width: 100px;
background-color: #ceDDce;
height: 50px;
text-align: center;
}

td.jongen{
color: black;
width: 100px;
background-color: #ceBBce!important;
height: 50px;
text-align: center;
}
td.meisje{
color: black;
width: 100px;
background-color: #ceAAce!important;
height: 50px;
text-align: center;


<?php
echo'<tr>
<td>'.$row['ID'].'</a></td>
<td>'.$row['NAAM'].'</td>
<td>'.$row['GESLACHT'].'</td>
<td>'.$row['BLA'].'</td>
<td>'.$row['BLA'].'</td>
echo'</tr>';
?>
Ik denk dat de volgende code wel werkt:


<body>
<style>
textarea, input, button,
a, td, span{
font-family: "Trebuchet MS", Helvetica, sans-serif;
}

td{
color: black;
width: 100px;
background-color: #ceDDce;
height: 50px;
text-align: center;
}

td.jongen{
color: black;
width: 100px;
background-color: #ceBBce!important;
height: 50px;
text-align: center;
}
td.meisje{
color: black;
width: 100px;
background-color: #ceAAce!important;
height: 50px;
text-align: center;



<?php
echo'<tr>
<td>'.$row['ID'].'</a></td>
<td>'.$row['NAAM'].'</td>
<td class="'. $row['geslacht'] == 'jongen' ? 'jongen' : 'meisje' .'">'.$row['GESLACHT'].'</td>
<td>'.$row['BLA'].'</td>
<td>'.$row['BLA'].'</td>
</tr>';
?>


Nee, helaas.

dan krijg ik een rare layout

Toevoeging op 27/10/2014 17:33:57:

Maar met bovenstaande verander ik alleen die ene "cel", ik wil eigenlijk dat de hele rij verandert van kleur.

Moet ik dan eigenlijk niet iets maken van:

<tr>
<td class="'. $row['geslacht'] == 'jongen' ? 'jongen' : 'meisje' .'">

en dan voor elke .$row

ipv <td> <td class> ?

Reageren