Order by Math Problem

3 posts by 2 authors in: Forums > CMS Builder
Last Post: September 9, 2009   (RSS)

By Kenny - September 9, 2009

I got basic php math down with no problem, but i have a problem that escapes me at the moment.

Let's say:

field 1 = number of wins
field 2 = number of ties

A win = 3 points and a tie = 1 point

Team A has 3 wins and 2 ties so they have 11 points

So something like <?php echo number_format($record['won'] *3 + $record['tied'] *1) ?> would do the trick.

But now I need to sort these teams according to who has the most points.

Help?

Kenny

Re: [sagentic] Order by Math Problem

By Dave - September 9, 2009

Hi Kenny,

Try this:
'orderBy' => "(won*3) + (tied*1) DESC",

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com