html - Insert inline css/Style for If / else php -


i need style table depending on status. example completed = green & pending = orange

php code. pulling data mysql

    $query = mysql_query("select * cashouts uid = ".$auth->getloggedid()." order id desc limit $offset, $showperpage");     while($row = mysql_fetch_object($query))     {     $username = $row->username;      $amount = $row->amount;     $status = $row->status;     $method = $row->method;           $priority = $row->priority;                if($status == 'complete' && !empty($row->payment_date))     $date = date("d m, y",strtotime($row->payment_date));         else     $date = date("d m, y",strtotime($row->request_date));    $payments[] = array('date' => $date, 'amount' => $amount, 'method' => $method, 'status' => $status, 'cycle' => $priority); 

}

my tpl/html file code

    <tbody>      {if $payments ne ""}     {foreach item=payment from=$payments}     <tr>     <td>{$payment.date}</td>     <td>${$payment.amount}</td>     <td>{$payment.method}</td>     <td>{$payment.status}</td>     <td>{$payment.cycle}</span></td>     </tr>     {/foreach}     {/if}      </tbody> 

what need if status = completed then

    <td style="color: green;">{$payment.status}</td> 

else if status = pending then

    <td style="color: orange;">{$payment.status}</td> 

add case in sql select statement.

case status     when 'completed' 'green'     when 'pending' 'orange'     else '' end color  $color = $row->color  <td style="color: {$payment.color};">{$payment.status}</td> 

Comments