Answer the question
In order to leave comments, you need to log in
How to make alternating colors of rows in a table when calling data from a db?
Using PHP, I retrieve data from the database like this:
<?PHP
$db->Query("SELECT * FROM db_spisok WHERE user_id = '$usid' ORDER BY id DESC LIMIT 20");
if($db->NumRows() > 0){
while($user = $db->FetchArray()){
if ($user["start"] == 1) {
$yn= '<font color="#1b7b12"><b>Да</b></font>';
} else {
$yn= '<font color="#ba0000"><b>Нет</b></font>';
}
$date = date('d.m.Y', $add["date"]);
?>
<tr class="htt">
<td align="center"><?=$user["start"] ?> </td>
<td align="center"><?=$date; ?></td>
<td align="center"><?=$yn; ?></td>
</tr>
<?PHP
}
}else echo '<tr><td align="center">Нет записей</td></tr>'
?>
Answer the question
In order to leave comments, you need to log in
I use the Datatable plugin in the output interface, very convenient tables are obtained at the output. And the "chess" that you want will be there. In addition to pagination, search, sorting - even export to XLS / CSV can be done on the client side (via a SWF gadget). Definitely handy, I recommend.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question