title: sum multiple columns from one table
body: <p>i have mysql table have 4 columns (product1,sample1,peoduct2,sample) I want to make query to get the sum of cells on sample1 &amp; sample32 where product1 or product2 = 4</p>
  
  <p>I use </p>
  
  <pre><code>$query="SELECT (SELECT SUM(sample1) FROM table WHERE product1= 4) + (SELECT SUM(sample2) FROM table WHERE product2 = 4)  AS SumCount";
  
  $result = mysql_query($query) or die(mysql_error());
  while($row=mysql_fetch_array($result)){ ?&gt;
      &lt;td&gt;
      echo $row[1];           
  }
  
      product1       sample1        product2     sample2
  -------------  -----------      -----------   ----------- 
  5                 1                  3            5   
  7                 3                  4            6
  4                 7                  8            7
  10                8                  9            9
  4                 2                  2            8
  2                 5                  2            8  
  </code></pre>
  
  <p>the results should be for value 4 (7 + 2 + 6) but i make loop for all products like this    </p>
  
  <p>4   15
  2   21                                  </p>
  
  <p>but it give me 1 row not multi rows products</p>