Welcome Guest, Not a member yet? Register   Sign In
convert sql
#5

(09-20-2021, 11:53 PM)Tajar_Dobro Wrote: ikeselayes , you can.

Code:
Select if(payment_status=0,'Not Paid','Paid ') AS status

tnanksss,
but what about if i have more than 2 status?

Hi,

You could also display the statuses using PHP instead of SQL.

Code:
function getPaymentStatus($status)
{
  $statuses = [
    0 => 'Not Paid',
    1 => 'Paid',
    2 => 'Third Status'
  ];
  return isset($statuses[$status]) ? $statuses[$status] : "Unknown Status: {$status}";
}

foreach ($result as $row) {
  echo getPaymentStatus($row['status']) . '<br>';
}
Reply


Messages In This Thread
convert sql - by Tajar_Dobro - 09-20-2021, 04:19 AM
RE: convert sql - by nfaiz - 09-20-2021, 05:44 AM
RE: convert sql - by ikesela - 09-20-2021, 10:28 AM
RE: convert sql - by Tajar_Dobro - 09-20-2021, 11:53 PM
RE: convert sql - by paulkd - 09-21-2021, 12:51 AM
RE: convert sql - by includebeer - 09-21-2021, 03:21 PM



Theme © iAndrew 2016 - Forum software by © MyBB