Hallo zusammen,
ich sitze jetzt nun schon ewig davor und versuche einfach eine Tabelle die Zahlen in der Spalte $row['credit'] enthält bei kleiner 0 rot einzufärben.
Wie gesagt es geht um die Splate "credit". theoretisch müsste ich direkt nach der while schleifen abfragen wenn der wert kleiner 0 ist.
Aber ich noch nicht herausgefunden wie die Tabelle ansprechen muss das sich die Farbe der Zahl ändert.
Bestimmt total einfach, ich habe nur ein Brett vor dem Kopf
Danke euch
ich sitze jetzt nun schon ewig davor und versuche einfach eine Tabelle die Zahlen in der Spalte $row['credit'] enthält bei kleiner 0 rot einzufärben.
PHP-Code:
<table id="tbl_kunden" class="table tablesorter">
<thead>
<tr>
<th># ID</th>
<th><?php echo $customers['firstname']; ?></th>
<th><?php echo $customers['lastname']; ?></th>
<th><?php echo $customers['tagid1']; ?></th>
<th><?php echo $customers['tagid2']; ?></th>
<th><?php echo $customers['admin']; ?></th>
<th><?php echo $customers['credit']; ?></th>
<th><?php echo $customers['actions']; ?></th>
</tr>
</thead>
<tbody>
<?php
include("inc/db_connect.php");
$stmt = $dbh->prepare("SELECT * FROM customers");
$stmt->execute();
while($row = $stmt->fetch())
{
if ($row['admin']==1)
{
$row['admin'] = "ja";
}
else
{
$row['admin'] = "Nein";
}
echo "<tr>";
echo "<td>" . $row['k_id'] . "</td>";
echo "<td>" . $row['firstname'] . "</td>";
echo "<td>" . $row['lastname'] . "</td>";
echo "<td>" . $row['tagid1'] . "</td>";
echo "<td>" . $row['tagid2'] . "</td>";
echo "<td>" . $row['admin'] . "</td>";
echo "<td>" . $row['credit'] . "</td>";
echo "<td><a href="#"><span class="glyphicon glyphicon-pencil" aria-hidden="true" data-toggle="modal" data-target="#modal_kunde_bearbeiten" data-id="".$row['k_id'].""></span></a>
<a href="kunden/loeschen/".$row['k_id']."" onclick="return confirm('" . $customers['delete'] . "');"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
<a href="kunden/loeschen/".$row['k_id']."" onclick="return confirm('" . $customers['delete'] . "');"><span class="glyphicon glyphicon-euro" aria-hidden="true"></span></a>
<a href="kunden/loeschen/".$row['k_id']."" onclick="return confirm('" . $customers['delete'] . "');"><span class="glyphicon glyphicon-signal" aria-hidden="true"></span></a></td>";
echo "</tr>";
}
?>
</tbody>
</table>
PHP-Code:
if ($row['creidt']<0)
{
echo color:"red";
}
else
{
echo color:"green";
}
Bestimmt total einfach, ich habe nur ein Brett vor dem Kopf
Danke euch
Kommentar