title: How to sum the similar data based on id in foreach loop
body: <p>I have such a scenario where 
  there is a loop in that loop i m getting 3 DIFFERENT data and each having different no of quantity:
  like:
  total data based on id:
  2
  is count
  2</p>
  
  <p>total data based on id:
  5
  is count
  2</p>
  
  <p>total data based on id:
  6
  is count
  1
  so what I want is I want to addd that count to show 5 i.e.(2+2+1 => counts)</p>
  
  <p>Query I done like:</p>
  
  <pre><code>foreach($test as $user)
              {
                  echo "total data based on id:";
                      //echo $user;
                      echo "&lt;pre&gt;";
                      print_r($user-&gt;id);
                      echo "&lt;/pre&gt;";
                      echo "&lt;br&gt;";    
      $enroll_count =  $this-&gt;dbop-&gt;countcustomQuery("SELECT *  FROM data where userid='".$user-&gt;id."' and DATE(created_on) = CURDATE() - 1");
  
                    echo "is count";
  
                      echo "&lt;pre&gt;";
                      print_r($enroll_count);
                      echo "&lt;/pre&gt;";
  }                   echo "&lt;br&gt;";    
  </code></pre>