dimanche 6 septembre 2015

Checking if table cell blocks have data and if so change the styling

I created a table that I am using as a draft board. There are users and then players they have to pick. I am wondering if a user has picked a player if there is anyway I can style that cell block in a different color style to show that block more significantly that it was picked. Then the empty blocks leave the normal styling.

I created a fiddle to show the table somewhat how it looks.

http://ift.tt/1M2XC5M

So the cells that have names in them I was wondering if I could make them a different color.

<table class="draft_border_table">
<tr>
    <th class="draft_table_number_th">RND</th>

<?php

// Output usernames as column headings
$userResults = mysqli_query($con, 'SELECT * FROM user_players ORDER BY `id`');
while($userPlayer = mysqli_fetch_array($userResults)) {
    $userPlayerStore[] = $userPlayer;
    echo '<th class="draft_table_th"><div>' . $userPlayer['username'] . '</div></th>';
}

?>

    </tr>

<?php

// Output each user's player 1-14 in each row
$totalPlayerNumbers = 14;
for ($playerNum = 1; $playerNum <= $totalPlayerNumbers; $playerNum++) {
    echo '<tr><td><div class="draftBorder">' . $playerNum . '</div></td>';
    foreach ($userPlayerStore as $userPlayer) {
        echo '<td class="draft_table_td">' . $userPlayer['player' . $playerNum] . '</td>';
    }
    echo '</tr>';
}

?>

</table>

Aucun commentaire:

Enregistrer un commentaire