Hi...

I have codes in uploading .xml file to my database table, now I only need to save or insert only the data where ETD (Month from Date) is not previous Month.

ETD = date

Actually it's my first time to encounter this and while I'm posting this issue in forums., I also tried to find the answer.
here is my code:

PHP Code:
<?php
error_reporting
(E_ALL E_NOTICE); 
date_default_timezone_set("Asia/Singapore"); //set the time zone    
$data = array();

$con mysql_connect("localhost""root","");
if (!
$con) { 
  die(
mysql_error());
}
$db mysql_select_db("mes"$con);
if (!
$db) { 
  die(
mysql_error());
}
$date_now date('m');

function 
add_employee($ETD,$PO_No,$SKUCode,$Description,$POReq ,$Comp)
  {
      global 
$data;
            
      
$con mysql_connect("localhost""root","");
      if (!
$con){ die(mysql_error());}
      
$db mysql_select_db("mes"$con);
      if (!
$db) { 
          die(
mysql_error());
      }

      
$ETD$ETD;
      
$PO_No $PO_No;
      
$SKUCode $SKUCode;
      
$Description $Description;
      
$POReq $POReq;
      
$Comp $Comp;
     

      
$sql "INSERT INTO sales_order (ETD,PO_No,SKUCode,Description,POReq,Comp) 
      VALUES 
      ('
$ETD','$PO_No','$SKUCode','$Description','$POReq','$Comp')
      " 
or die(mysql_error());
      
mysql_query($sql$con);
      
       
$data []= array('ETD'=>$ETD,'PO_No'=>$PO_No,'SKUCode'=>$SKUCode,'Description'=>$Description,'POReq'=>$POReq,'Comp'=>$Comp); 
}

if(empty(
$_FILES['file']['tmp_name'])){
$doc = new DOMDocument();
$dom $doc->load('Sales1.xml');
      
$rows $doc->getElementsByTagName('Row');
      global 
$last_row;
      
$last_row false;
      
$first_row true;
      foreach (
$rows as $row)
      {
          if ( !
$first_row )
          {
              
$ETD "";
              
$PO_No "";
              
$SKUCode "";
              
$Description "";
              
$POReq "";
              
$Comp "";
              
              
$index 1;
              
$cells $row->getElementsByTagName'Cell' );
          
              foreach( 
$cells as $cell )
              { 
                  
$ind $cell->getAttribute'Index' );
                  if ( 
$ind != null $index $ind;
              
                  if ( 
$index == $ETD $cell->nodeValue;  
                  if ( 
$index == $PO_No $cell->nodeValue;
                  if ( 
$index == $SKUCode $cell->nodeValue;
                  if ( 
$index == $Description $cell->nodeValue;
                  if ( 
$index == $POReq $cell->nodeValue;
                  if ( 
$index == $Comp $cell->nodeValue;
                  
$index += 1;
              }

             if (
$ETD=='' AND $PO_No=='' AND $SKUCode=='' AND $Description=='' AND $POReq=='' AND $Comp=='') {  
                    
$last_row true;
              }      
              else {
                    
add_employee($ETD,$PO_No,$SKUCode,$Description$POReq$Comp);  
              }      
          }
          if (
$last_row==true) {
              
$first_row true;
          }     
          else {
              
$first_row false;
          }
      }
  }  
 
  
?>
I tried this query:

Code:
$sql = "INSERT INTO sales_order (ETD,PO_No,SKUCode,Description,POReq,Comp) 
      VALUES 
      ('$ETD','$PO_No','$SKUCode','$Description','$POReq','$Comp')
      WHERE $ETD_month != '$date_now'" or die(mysql_error());
but still he get date where ETD(month from date) = March.

Thank you so much