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

Link to comment
Share on other sites

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']

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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!)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.