I have several calculated columns that I need to sort by (sort buttons in column headers). I've figured out most of the columns. However one uses several if statements to determine the calculation used on each row (see code below).
// Column: Payout
if (($row['SoldBy']=='GT') && ($row['BookedBy']=='GT')) {
$PayOut = 0;
echo '<td bgcolor="fffff0">$'.number_format($PayOut,2,'.',',').'</td>';
}
elseif (($row['SoldBy']=='GT') && ($row['BookedBy']=='TC')) {
$PayOut = $Margin*.2;
echo '<td bgcolor="fffff0">$'.number_format($PayOut,2,'.',',').'</td>';
}
elseif (($row['SoldBy']=='GT') && ($row['BookedBy']=='')) {
$PayOut = $Margin*.2;
echo '<td bgcolor="fffff0">$'.number_format($PayOut,2,'.',',').'</td>';
}
elseif (($row['SoldBy']=='TC') && ($row['BookedBy']=='GT')) {
$PayOut = $Margin*.4;
echo '<td bgcolor="fffff0">$'.number_format($PayOut,2,'.',',').'</td>';
}
elseif (($row['SoldBy']=='TC') && ($row['BookedBy']=='TC')) {
$PayOut = $Margin*.6;
echo '<td bgcolor="fffff0">$'.number_format($PayOut,2,'.',',').'</td>';
}
elseif (($row['SoldBy']=='TC') && ($row['BookedBy']=='')) {
$PayOut = $Margin*.6;
echo '<td bgcolor="fffff0">$'.number_format($PayOut,2,'.',',').'</td>';
}
I know about including a "sum(ColumnA-Column😎 AS ColumnC" type of thing in my SELECT statement, but how can I sort this column since it's not just simple math, or even the same math used on each (depending on what's going on in my table-based columns of BookedBy and SoldBy?
Can provide more of the code if needed. Figured this would be enough hopefully.