![]() |
Sum of MySQL rows values and sum of values shouldn't be greater than php variable - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Sum of MySQL rows values and sum of values shouldn't be greater than php variable (/showthread.php?tid=77166) |
Sum of MySQL rows values and sum of values shouldn't be greater than php variable - olegrain - 07-28-2020 Hello! I use Codeigniter 3.1.11 and have a php variable $maximum_amount with value of '0.50000000'. In my MySQL database I have a table called 'orders' with a rows for example: Code: #table orders I need to select rows with SUM of 'amount' but the SUM of 'amount' shouldn't be be greater than variable $maximum_amount. I need to use order ASC by 'created_time' and limit '100'. I know what I need to use Cumulative Sum, but I don't know how to do it with Codeigniter. Please, help to solve this. RE: Sum of MySQL rows values and sum of values shouldn't be greater than php variable - php_rocs - 07-28-2020 @olegrain, What code do you currently have in place to do a pull from the database? The query that your asking for is not complicated but are you asking for the code as well? |