Forum Moderators: coopster
I have a fairly basic code snippet below that will fetch data from MySQL and place it into an array. From this array, I am displaying the results in a table with 1 row for each row fetched. What i want is to somehow incorporate an IF ELSE statement to change the font color of the status field. Example, if the status is Confirmed, then i want the font color to be green. If it is anything else, I want it to be red. I have tried including and IF statement from within the ECHO command below but I just cant seem to get the proper syntax. Can anybody assist? I have included the snippet im using below. THANKS!
<?php
while($abc=mysql_fetch_array($xyz)){
echo "
<tr>
<td>{$abc['month']}</td>
<td>{$abc['day']}</td>
<td>{$abc['year']}</td>
<td>{$abc['time']}</td>
<td>{$abc['type']}</td>
<td>{$abc['status']}</td>
</tr>";
}
?>
<?php
while($abc=mysql_fetch_array($xyz)){
echo "
<tr".($abc['status']=='Confirmed' ? ' style="color:#00FF00"' : ' style="color:#FF0000"').">
<td>{$abc['month']}</td>
<td>{$abc['day']}</td>
<td>{$abc['year']}</td>
<td>{$abc['time']}</td>
<td>{$abc['type']}</td>
<td>{$abc['status']}</td>
</tr>";
}
?>
[edited by: Vis3R at 5:56 pm (utc) on Feb. 28, 2008]