dudejma Posted July 12, 2010 Share Posted July 12, 2010 Hello. I have this code, which works: <?php $con = mysql_connect("localhost","virtu857_invoice","J497"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("virtu857_invoice", $con); $result = mysql_query("SELECT * FROM invoices") or die("Error: " . mysql_error()); echo "<table border='1'> <tr> <th>ID</th> <th>Client ID</th> <th>Date Billed</th> <th>Date Due</th> <th>Date Paid</th> <th>Total</th> <th>Status</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['clientid'] . "</td>"; echo "<td>" . $row['bill_date'] . "</td>"; echo "<td>" . $row['due_date'] . "</td>"; echo "<td>" . $row['paid_date'] . "</td>"; echo "<td>" . $row['total'] . "</td>"; echo "<td>" . $row['status'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> I'm wanting to make the status row change from red if it is: pending, but green if it is: paid. Thanks! Link to comment https://forums.phpfreaks.com/topic/207463-changing-color/ Share on other sites More sharing options...
BillyBoB Posted July 12, 2010 Share Posted July 12, 2010 So something like this: <?php $con = mysql_connect("localhost","virtu857_invoice","J497"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("virtu857_invoice", $con); $result = mysql_query("SELECT * FROM invoices") or die("Error: " . mysql_error()); echo "<table border='1'> <tr> <th>ID</th> <th>Client ID</th> <th>Date Billed</th> <th>Date Due</th> <th>Date Paid</th> <th>Total</th> <th>Status</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['id'] . "</td>"; echo "<td>" . $row['clientid'] . "</td>"; echo "<td>" . $row['bill_date'] . "</td>"; echo "<td>" . $row['due_date'] . "</td>"; echo "<td>" . $row['paid_date'] . "</td>"; echo "<td>" . $row['total'] . "</td>"; if($row['status']=="paid") { echo "<td style=\"color: green;\">$row[status]</td>"; }else{ echo "<td style=\"color: red;\">$row[status]</td>"; } echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Good luck Link to comment https://forums.phpfreaks.com/topic/207463-changing-color/#findComment-1084661 Share on other sites More sharing options...
dudejma Posted July 12, 2010 Author Share Posted July 12, 2010 Thanks SO much! Link to comment https://forums.phpfreaks.com/topic/207463-changing-color/#findComment-1084688 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.