Question: I have if conditions that display depending on the value in sql database column.
What I am trying to achieve is to have different colors for each output. This is my code

```html
<?php $statusshow  = $row0["accStatus"]?>
    <p>Status:> <?php
     if ($statusshow == "1") {echo "Pending Confirmation!";}
     elseif ($statusshow == "2") {echo "Confirmed!";}
     elseif ($statusshow == "3") {echo "Processing..";}
     elseif ($statusshow == "4") {echo "Declined";}                            
     ?></p>

```

I would like pending confirmation to be red, confirmed to be green, processing to be yellow and declined to be red. How can I achieve this?

Answer: 
To minimize codelines you can add a function which will return text message and style for provided input:

```
function getMessageAndColor($status) {
    if ($status == "1") {return ["Pending Confirmation!", "color: red;"];}
    elseif ($status == "2") {return ["Confirmed!", "color: green;"];}
    elseif ($status == "3") {return ["Processing..", "color: yellow;"];}
    elseif ($status == "4") {return ["Declined", "color: red;"];}
}

[$message, $color] = getMessageAndColor($row0["accStatus"]);?>
<p>Status:<span style="<?=$color?>"><?=$message?></p>

```
```html
<?php $statusshow  = $row0["accStatus"]?>
<p>Status:> 
<?php
   if ($statusshow == "1") {
     echo "<span style='color: green'>Pending Confirmation!</span>";
   }
   elseif ($statusshow == "2") {
     echo "<span style='color: green'>Confirmed!</span>";
   }
   elseif ($statusshow == "3") {
     echo "<span style='color: yellow'>Processing...</span>";
   }
   elseif ($statusshow == "4") {
     echo "<span style='color: red'>Declined</span>";
   }
?>
</p>
```