php - Sort database records by cost but as if the cost was incremented by 1p per day? -


i'm wondering if it's possible add little maths sorting database mysql , php.

in short, friend wanting website people pay want service, attention go higher payments, , work down lower ones when has time.
the easy way order records amount paid, mean payment of 5p priority on that's been sitting there 20 days, had idea of incrementing amount paid 1p per day.

is there way sql statement doesn't involve writing table, or should php array , calculations there? alternatively worth having 2 tables in database, 1 incremented cost, , other keep track of when last updated, avoid having recalculate more once day?

i'd try have efficient solution, , while php calculation route seems easiest, i'd have process records @ once , sort them, might quite heavy on server.

you can using datediff():

order payment + datediff(curdate(), submitdate) desc 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -