Jump to content

[SOLVED] XML To PHP To MySQL Confused?


Crew-Portal

Recommended Posts

I sure am. Confused I mean. If I can take MySQL Run it through PHP and get XML why cant I do it the other way.

<FlightPlans>
<FlightPlan>
  <StatusText>Open</StatusText> 
  <PlayerName>N350CA</PlayerName> 
  <TimeFiledText>07:11 PM</TimeFiledText> 
  <TimeOpenedText>07:11 PM</TimeOpenedText> 
  <TimeClosedText />
  <TimeOpened>07:11 PM</TimeOpened> 
  <TimeClosed>09:53 PM</TimeOpened> 
  <OpenTimeText>0d 2h 47m</OpenTimeText> 
  <Plan>KDFW-KLAX, 737, 35,000'</Plan> 
</FlightPlan>
</FlightPlans>

^^^ That is my XML code that gets updated twice per second. I need a code that can take the XML above and put it into a mysql table called flights. The colums that need to be filled with data is PlayerName, TimeOpened, TimeClosed, OpenTimeText, And OpenTimeText But I only want it to insert that information into the database if the StatusText == Closed, And I would like it to insert the data without a user needing to be on the website (But if a user needs to be on thats okay too) Can someone help me out and give me the code? I think it has something to do with explode and stuff? but im not exactly 100% sure, thats why I would be very appreciative if someone could just pend 5 minutes if they know how to write it.

Link to comment
https://forums.phpfreaks.com/topic/76937-solved-xml-to-php-to-mysql-confused/
Share on other sites

When I do that it returns:

http://24.76.166.219/index.php?page=xml

 

So how in the world do I go about translating that gibberish into a SQL Query? All before the:

                    [FLIGHTPLANS] => Array

                        (

                            [0] => Array

                                (

                                    [FLIGHTPLAN] => Array

                                        (

                                            [0] => Array

                                                (

Is just gibberish and I dont need it inserted into any database just the flight plans section of the XML, For all of you that want to know the full path to the XML is here

So how in the world do I go about translating that gibberish into a SQL Query?

                 

Is just gibberish and I dont need it inserted into any database just the flight plans section of the XML,

 

That ain't gibberish and you are contradicting your self. its a print_r of your array, just use a query and pick and choose the varibles you would like like

$array['node1']['data1']

Okay I sorta get it but ould you do one quick thing. look at http://24.76.166.219/index.php?page=xml Now lets say I wanted to take the SERVERNAME out of that and put it in an echo statement how would I go about doing that? Because my array doesnt have a variable called $array as a matter of fact I dont even know what my array variable is called?

Oh nvm there was a ['0']; in the array that I didnt see and that was the reason I couldnt echo the array! cooldude832 And rajivgonsalves You guys are awesome thank you so much, you just made me and a few members of my site very happy. Keep up the good work. You are great at what you do! Woot! Woot! Ya! Im so happy right now you just dont have a clue! Thank you! Thank you! Thank you! Nice work!

 

TOPIC SOLVED!!!

(Im Cryin' Im so Happy!)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.