Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7894479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:24:28+00:00 2026-06-03T07:24:28+00:00

First, I’m not experienced with PHP whatsoever. I have 2 arrays – minimumpressure and

  • 0

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:-

<pressuremaxhourly>1010,1009,1009,1009,1008,1008,1007,1005,1004,1003,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1001,1001,1001</pressuremaxhourly>
<pressureminhourly>1001,1009,1009,1008,1008,1006,1005,1004,1003,1002,1002,1002,1002,1002,1002,1002,1002,1002,1002,1001,1001,1001,1001,1001</pressureminhourly>

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:-

$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->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->MINBP;
}

And here’s the code used to create the xml file:-

$dom = new DOMDocument(); 
$root = $dom->createElement( "weatherdata" );
$dom->appendChild( $root );  
$item = $dom->createElement( 'item', "" );  
$root->appendChild($item);

$maxpressure = $dom->createElement( 'pressuremaxhourly', "$maxpressure[0],$maxpressure[1],$maxpressure[2],$maxpressure[3],$maxpressure[4], etc....for all values );  
$item ->appendChild($maxpressure);
$minimumpressure = $dom->createElement( 'pressureminhourly', "$minimumpressure[0],$minimumpressure[1],$minimumpressure[2],$minimumpressure[3],$minimumpressure[4], etc....for all values );  
$item ->appendChild($minimumpressure);
$dom->formatOutput = true;
$dom->save('Hourly.xml') 

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.

#####$$$$$ Update $$$$$$#######
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.

However when it’s run from the script above, the first element is always equal to the last element. IE. (minpressure[0] == minpressure[23])

Any further thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T07:24:29+00:00Added an answer on June 3, 2026 at 7:24 am

    How about creating the xml file like this :

    $dom = new DOMDocument(); 
    $root = $dom->createElement( "weatherdata" );
    $dom->appendChild( $root );  
    $item = $dom->createElement( 'item', "" );  
    $root->appendChild($item);
    
    $maxpressure = $dom->createElement( 'pressuremaxhourly', implode(",",$maxpressure) );  
    $item ->appendChild($maxpressure);
    $minimumpressure = $dom->createElement( 'pressureminhourly', implode(",",$minpressure));  
    $item ->appendChild($minimumpressure);
    $dom->formatOutput = true;
    $dom->save('Hourly.xml') 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, I'm not all that familiar with cookies but I know how they
First I explain the concept: I have two system both system have static ip
First of all, I'm not sure if the title accurately describes what I'm referring
First off, let me clarify the platforms we are using. We have an ASP.NET
First I want to thank you guys here, because your posts have gotten me
First, I have a dbcontext factory which is defined public class DatabaseFactory : Disposable,
First I will ask users How many names you want to enter?. Once they
First, I have a list of QWidget s that I won't know the length
First, my computer is windows 7 64bit, with xampp(apache, php, mysql), vmware server, java
First off, I am using Windows XP. I have multiple hard drives and it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.