There are numbers that comes into the database and I SUM up them with SUM , getting the total amount.

Numbers come every month. How to make it so that only the amount of the current month is displayed, i.e. today is 10/1/2016 and my amount is 100, tomorrow is 2/10/2016 - the amount is 350, and on reaching the end of the month the whole amount was reset and the countdown started again? This is in the module.

  public function getOrder(){ $query = $this->db->query("SELECT SUM(Sum_back) AS Sum_back, name_sender, order_id FROM `" . DB_PREFIX . "order` WHERE Sum_back > 0 GROUP BY name_sender"); return $query->rows; } 

this is the controller

  $senders = $this->model_module_limit->getOrder(); print_r($senders);die(); $this->data['senders'] = array(); foreach ($senders as $sender){ //$senders[] = "№–".$sender['order_id']; $this->data['senders'][] = array( 'name_sender' => $sender['name_sender'], 'Sum_back' => ($sender['Sum_back']), 'order_id' => $sender['order_id'] ); } 

this is vyushka

  <?php foreach($senders as $sender){ ?> <tr> <td class="left"><?php echo $sender['name_sender']; ?></td> <td class="left"><?php echo (date("dmY "));?></td> <?php if($sender['Sum_back']){ ?> <td class="left"><?php echo $sender['Sum_back']; ?></td> <?php } else { ?> <td class="left"><?php echo $massage?></td> <?php } ?> </tr> <?php } ?> 
  • "so that only the amount of the month of the month would be shown" - here for more specifically please - tCode
  • Give examples of the code you are using. What are you trying to do? What exactly does not work? - Samuel Loog
  • pastebin.com/8ieb08fC code - Roman Yushko
  • @RomanYushko insert the code in your question using the "Edit" button. - Denis
  • And what is your database. The functions for getting the current date (and month) in all databases are different. In general, you need to add a condition to the request that the date is greater than or equal to the first day of the current month and it is possible that it is less than or equal to the last (if there are records from the future in the database) - Mike

0