How would I make a page where I can select an XML file on my computer, upload it and have the data inserted into a mysql database?

    The XML would look something like:

    <Order>
    <ID='1'>
    <OrderNumber>55551</OrderNumber>
    <Status>Success</Status>
    <TrackingNumber>0249204920392</TrackingNumber>
    </ID>
    <ID='2'>
    <OrderNumber>55552</OrderNumber>
    <Status>Success</Status>
    <TrackingNumber>092309291444</TrackingNumber>
    </ID>
    <ID='3'>
    <OrderNumber>55553</OrderNumber>
    <Status>Failed</Status>
    <TrackingNumber></TrackingNumber>
    </ID>
    </Order>

    I'd need to get the status and tracking into the corresponding order's field in the database.

      upload the xml file,then get its content, analyze it
      some example

      <?php
      $str = "<Order>
      <ID='1'>
      <OrderNumber>55551</OrderNumber>
      <Status>Success</Status>
      <TrackingNumber>0249204920392</TrackingNumber>
      </ID>
      <ID='2'>
      <OrderNumber>55552</OrderNumber>
      <Status>Success</Status>
      <TrackingNumber>092309291444</TrackingNumber>
      </ID>
      <ID='3'>
      <OrderNumber>55553</OrderNumber>
      <Status>Failed</Status>
      <TrackingNumber></TrackingNumber>
      </ID>
      </Order>";
      
      preg_match_all("/<Status>(.*)<\/Status>/",$str,$arr);
      print_r ($arr);
      ?>

      hope will help

        What I'm wondering is how I would actually upload the file and then get it's contents into a variable. I also thought there might be some XML/PHP code you can use to extract information, otherwise how would I differentiate the status from Order 55551 from a different order?

          first,upload the file to the server,then you can use file_get_contents to get the centent,and analyze it.

            i am having a problem while uploading a images and video files.But in ie its working fine in firefox one time only i can upload images next time i couldn't upload images as well as videos.

              I got the file upload and store in variable part done but I'm unclear on how I can obtain the tracking and status of each order and link them to their associated order in the database.

              preg_match_all("/<Status>(.*)<\/Status>/",$str,$arr); would return all the statuses but wouldn't tell me which order the status is for, no?

                <?php 
                $str = "<Order> 
                <ID='1'> 
                <OrderNumber>55551</OrderNumber> 
                <Status>Success</Status> 
                <TrackingNumber>0249204920392</TrackingNumber> 
                </ID> 
                <ID='2'> 
                <OrderNumber>55552</OrderNumber> 
                <Status>Success</Status> 
                <TrackingNumber>092309291444</TrackingNumber> 
                </ID> 
                <ID='3'> 
                <OrderNumber>55553</OrderNumber> 
                <Status>Failed</Status> 
                <TrackingNumber></TrackingNumber> 
                </ID> 
                </Order>"; 
                
                preg_match_all("/<Status>(.*)<\/Status>/",$str,$arr); 
                preg_match_all("/<TrackingNumber>(.*)<\/TrackingNumber>/",$str,$tracking); 
                print_r ($arr); 
                print_r ($tracking); 
                ?>

                sorry,my English is not well,I don't get your mind completely😕

                  Write a Reply...