title: PHP - array element issue
body: <p>First, I'm not experienced with PHP whatsoever. I have 2 arrays - minimumpressure and maximumpressure. They both access data from a database and to create a simple xml file as you can see below:-</p>
  
  <pre><code>&lt;pressuremaxhourly&gt;1010,1009,1009,1009,1008,1008,1007,1005,1004,1003,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1001,1001,1001&lt;/pressuremaxhourly&gt;
  &lt;pressureminhourly&gt;1001,1009,1009,1008,1008,1006,1005,1004,1003,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1001,1001,1001,1001,1001&lt;/pressureminhourly&gt;
  </code></pre>
  
  <p>The problem is, as you can see, the 1st value of the minimum array is always equal to the last value of the maximum array ( in this case "1001"). These arrays are overwritten every half hour or so with new values, yet the the problem still exists. Here's the code I use:-</p>
  
  <pre><code>$MaxPressure="select hour(datetime) AS hour, max(BarometricPressure) as MAXBP from minute WHERE DATETIME
  BETWEEN (CURDATE() + INTERVAL (SELECT hour(NOW())) hour - INTERVAL 24 hour)
  AND ((CURDATE() + INTERVAL (SELECT hour(NOW()))hour))
  group by hour
  order by (CURDATE() + INTERVAL (SELECT hour(NOW())) hour - INTERVAL 24 hour)";
  $MaxPressureResult = mysql_query($MaxPressure) or  die('Failed to query'.mysql_error());
  
  while ($row = mysql_fetch_object($MaxPressureResult)) {
      $maxpressure[]=$row-&gt;MAXBP;
  }
  
  $MinimumPressure="select hour(datetime) AS hour, min(BarometricPressure) as MINBP from minute WHERE DATETIME
  BETWEEN (CURDATE() + INTERVAL (SELECT hour(NOW())) hour - INTERVAL 24 hour)
  AND ((CURDATE() + INTERVAL (SELECT hour(NOW()))hour))
  group by hour
  order by (CURDATE() + INTERVAL (SELECT hour(NOW())) hour - INTERVAL 24 hour)";
  $MinimumPressureResult = mysql_query($MinimumPressure) or  die('Failed to query'.mysql_error());
  
  
  while ($minrow = mysql_fetch_object($MinimumPressureResult)) {
      $minimumpressure[]=$minrow-&gt;MINBP;
  }
  </code></pre>
  
  <p>And here's the code used to create the xml file:-</p>
  
  <pre><code>$dom = new DOMDocument(); 
  $root = $dom-&gt;createElement( "weatherdata" );
  $dom-&gt;appendChild( $root );  
  $item = $dom-&gt;createElement( 'item', "" );  
  $root-&gt;appendChild($item);
  
  $maxpressure = $dom-&gt;createElement( 'pressuremaxhourly', "$maxpressure[0],$maxpressure[1],$maxpressure[2],$maxpressure[3],$maxpressure[4], etc....for all values );  
  $item -&gt;appendChild($maxpressure);
  $minimumpressure = $dom-&gt;createElement( 'pressureminhourly', "$minimumpressure[0],$minimumpressure[1],$minimumpressure[2],$minimumpressure[3],$minimumpressure[4], etc....for all values );  
  $item -&gt;appendChild($minimumpressure);
  $dom-&gt;formatOutput = true;
  $dom-&gt;save('Hourly.xml') 
  </code></pre>
  
  <p>Note: I've checked the data in the database and it's correct, so it's clearly the script that's the problem.
  Sorry for the long question and code sample, hopefully someone can help.</p>
  
  <p><em><strong>#####$$$$$ Update $$$$$$#######</em></strong>
  It seems the SQL script isn't the problem. I've left the interval at 24, and when I run the SQL script in my SQL workbench it's loading the correct results.</p>
  
  <p>However when it's run from the script above, the first element is always equal to the last element. IE. (minpressure[0] == minpressure[23])</p>
  
  <p>Any further thoughts?</p>