I am importing csv file into mysql DB. Csv file contains 4 columns, if the 4th column contains value "RTS - Return To Shipper" , than i want to skip that row when importing.....
if(isset($_POST["Import"])){
$filename=$_FILES["file"]["tmp_name"];
if($_FILES["file"]["size"] > 0)
{
$file = fopen($filename, "r");
$i=0;
while (($getData = fgetcsv($file, 10000, ",")) !== FALSE)
{
if($i==0){$i++;continue;}
$sql = "INSERT into do_order (tracking_id,
order_id,
payment_type
)
values ('".mysqli_real_escape_string($conn , $getData[0])."',
'".mysqli_real_escape_string($conn , $getData[1])."',
'".mysqli_real_escape_string($conn , $getData[2])."'
)
";
$result=$db_handle->executeUpdate($sql);
}
}
}
Just skip the line if you encounter the string you are looking for in the 4th column:
while (($getData = fgetcsv($file, 10000, ",")) !== FALSE)
{
if ($getData[3] == "RTS - Return To Shipper")
continue;
[...]