Heey mensen, ik heb de volgende code gevonden die een tabel aan maakt vanuit een mysql database (hij moet gewoon alle rows uit de mysql database laten zien)

nu is het zo, dat je 2 kleuren kan opgeven in een css file(?)

Maar helaas kom ik er niet uit hoe ik dat nu precies moet aanpakken.


    function GenerateTable($sqlResult, $Headers) {
                     $row = mysql_fetch_assoc($sqlResult);
                     $FieldList = Array_Keys($row);
                     echo "<table Border=2>";
                     Echo "<tr>";
                     For ($Cnt=0; $Cnt < Count($FieldList); $Cnt++) {
                              echo "<th>" . $Headers[$FieldList[$Cnt]] . "</th>";
                             }
                     echo "</tr>";
                     While ($row) {
                                  $RowColor = ($RowCnt % 2) ? "row1":"row2";
                                 Echo "<tr>";
                                 For ($Cnt=0; $Cnt < Count($FieldList); $Cnt++) {
                                          echo "<td class='$RowColor'>" . $row[$FieldList[$Cnt]] . "</td>";
                                         }
                                 echo "</tr>";
                                 $RowCnt++ ;
                                 $row = mysql_fetch_assoc($sqlResult);
                                 }
                     echo "</table>";
                     } 


By creating a CSS class for formatting you change more than color on each row.


Hoe moet ik dit nu precies doen? wat moet ik aanmaken in een .css file?

Ik hoop dat jullie me kunnen en willen helpen.
Thanxz alvast.
<style>

.row1 {
background-color: #fff;
}

.row2 {
background-color: #ccc;
}

</style>

zoiets?

Reageren