phpmysqlcodeigniterbetweendiscount

Calculate tiered discount amount using a CodeIgniter query


I have a discount lookup table like this:

days discount
3 5.00
7 10.00
10 15.00

Basically the tiered discount lookup works like this:

If the passed-in days number is 5, then the query should return 10.00.

How can I write a CodeIgniter query to perform this logic?


Solution

  • SELECT discount FROM mytable WHERE days > XXXX LIMIT 1 where XXX is the number of days you want.