title: sum of multiple products with show rows concerned using array
body: <p>I have a table that has 3 products description (Product_1, Product_2, Product_3) and Each product of some reference AND quantity with location of every row</p>
  
  <p>Iwant show all rows for product_1, product_2, product_3 which the sum of each product on Array variable as an example </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>$globalProduct = array(21000, 18000, 1000);
  
  $sumProduct_1 = $globalProduct[0];
  $sumProduct_2 = $globalProduct[1];
  $sumProduct_3 = $globalProduct[2];</code></pre>
  </div>
  </div>
  </p>
  
  <p>Ihave query mysql for one product but I found it difficult to use 3 products.</p>
  
  <p>this query for one product, it's working correctly</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>SET @runtot=0;
  SELECT p_reference, p_id, p_description, p_quantity, p_location, (@runtot := @runtot + p_quantity) AS runningTotal
  FROM (
      SELECT p_reference, p_id, p_description, p_quantity, p_location
      FROM product_table
      WHERE p_description = 'product_1'
      ORDER BY p_reference, p_quantity
  ) AS l
  WHERE @runtot &lt;= 21000;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>this follow source code for create Product_table</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>CREATE TABLE IF NOT EXISTS `product_table` (
  `p_id` int(11) NOT NULL,
    `p_description` varchar(50) NOT NULL,
    `p_reference` varchar(25) NOT NULL,
    `p_location` varchar(25) NOT NULL,
    `p_quantity` float(11,3) NOT NULL
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;
  
  --
  -- Contenu de la table `product_table`
  --
  
  INSERT INTO `product_table` (`p_id`, `p_description`, `p_reference`, `p_location`, `p_quantity`) VALUES
  (1, 'Product_1', '1A00001', 'QD01', 7000.000),
  (2, 'Product_1', '1A00001', 'QD02', 7000.000),
  (3, 'Product_1', '1A00007', 'QD03', 7000.000),
  (4, 'Product_1', '1A00008', 'QD04', 7000.000),
  (5, 'Product_2', '1A00002', 'AB01', 6500.000),
  (6, 'Product_2', '1A00004', 'AB02', 6500.000),
  (7, 'Product_2', '1A00005', 'AB03', 6500.000),
  (8, 'Product_2', '1A00003', 'DB01', 6500.000),
  (9, 'Product_2', '1A00009', 'DB02', 6500.000),
  (10, 'Product_2', '1A00002', 'DB03', 6500.000),
  (11, 'Product_2', '1A00002', 'DB04', 6500.000),
  (12, 'Product_3', '1A00010', 'FD01', 5000.000),
  (13, 'Product_3', '1A00015', 'DS02', 5000.000),
  (14, 'Product_3', '1A00017', 'DS03', 5000.000),
  (15, 'Product_3', '1A00018', 'DS04', 5000.000);</code></pre>
  </div>
  </div>
  </p>