hi,
i want to use condition for display data in column from MY TABLE .And in DB value is 0,1,2,3, and i want to display like AB,AJ,RF,COD how to display like this in column,sir
if value 0 display AB,if value is 1 display AJ,like this in column…
thanks sir..
You can use IF condition in select_command query.
IF(field=0,"AB", IF (field=1, "AJ", IF (field=2, "RF", "COD"))) as field
$g->select_command = "SELECT DISTINCT tblorders.OrderId,tblorders.userId, tbluser.fullName,tblorders.Totalinvoice,tblorders.PaymentStatus,tblorders.SubTotal
FROM tbluser
INNER JOIN tblorders ON tbluser.userId= tblorders.userId IF(PaymentStatus=0,"due", IF (PaymentStatus=1, "AJ", IF (PaymentStatus=2, "RF", "COD")))";
its not working …same value is displaying..
IF clause is part of column selection in query.
It would be something like:
$g->select_command = "SELECT DISTINCT tblorders.OrderId,tblorders.userId, tbluser.fullName,tblorders.Totalinvoice,
IF(tblorders.PaymentStatus=0,"due", IF (tblorders.PaymentStatus=1, "AJ", IF (tblorders.PaymentStatus=2, "RF", "COD")))
as PaymentStatus
,tblorders.SubTotal
FROM tbluser
INNER JOIN tblorders ON tbluser.userId= tblorders.userId";
If issue persist, refer mysql query manual for IF clause use.