title: PHP&MySQL: issue using php for and mysql query
body: <p>I would calculate the total profit of a DataBase for each month using 12 different function [one for each month(yes its probably not a nice solution but I am learning step by step )]</p>
  
  <p>This is the .php code (x12 times)</p>
  
  <pre><code>$January="SELECT JanuaryProfit()";     //Function
  echo "&lt;b&gt;January Profit: E&lt;/b&gt;";
  $January = mysql_query($giugno,$conn)
            or die("Query failed: " . mysql_error($conn));
  $num_rows=mysql_num_rows($January);
  
  if (! $num_rows)
        echo "&lt;p&gt;0&lt;/p&gt;";
  else {
        while ($row = mysql_fetch_row($January)) {
              $price=$row[0];
              echo "$price";
        };
  }
  </code></pre>
  
  <p>Function JanuaryProfit() is declared this way [MySQL]:</p>
  
  <pre><code>BEGIN
  DECLARE PriceTOT FLOAT;
  SELECT SUM(o.PrezzoTot) INTO PriceTOT
  FROM orders o
  WHERE o.Data BETWEEN '2012-01-01' AND '2012-01-31';
  RETURN PriceTOT;
  END
  </code></pre>
  
  <p>And so I've declared singularly february,march,...,december.</p>
  
  <p>I wouldn't paste 12 times the first code into the .php page.I've tried using a for cicle that use different function every time but i cannot figure how to solve this,correctly.Any suggest?</p>
  
  <p>All I wanna do by now is changing the php part only,using a loop.</p>