```
Parts No    Mfg     Cond    LowPrice    AvgPrice    HighPrice  Weighted TotalQty
002805-00   3COM    NEW     25          25          25         N/A      1
0231A085    3COM    NEW     133.75      133.75      133.75     N/A      3
0231A61N    3COM    NEW     253.58      253.58      253.58     N/A      2
0231A61P    3COM    NEW     467.25      467.25      467.25     N/A      1

```

i wana add only partno , mfg and price from this csv format into the table having different field name as define in 1st row but table also contain some other fields.

This is right way to insert??????? Suggestions.

```
    if (($handle = fopen("sample.csv", "r")) !== FALSE) {
              while (($data = fgetcsv($handle, 10000, ",")) !== FALSE) {

                $i=0;
                if ($scount == 0) {  
                        foreach ($data as $key=>$value){
                         $item[$i++] = $value; 
                         if($value == 'Parts No') $c1 = $key;
                         if($value == 'Mfg') $c2 = $key;if($value == 'Cond') $c3 = $key;

                         if($value == 'AvgPrice') $c4 = $key;

                        }

                }else{
                if($data[$c3] == "NEW" || $data[$c3] == "new"){
                mysql_query("insert into  vable (partno,brand,price)
                    values('".$data[$c1]."','".$data[$c2]."','".$data[$c4]."') ",);}
                }

                $scount++; 

        } 

```