title: How to fetch single row/data from Mysql_fetch_array?
body: <p>I am reading .csv file through PHP using fgetcsv(). Now I am able to fetch I mean read data from .csv file.
  Then I need to check SKU column with my fetch result &amp; accordingly have to perform either Insertion Or Updation. 
  Suppose SKU is already present there, then I have to update my row in table else I need to insert new record.
  I have write following code...Plz check n tell me where I am doing mistake-:</p>
  
  <pre><code>&lt;?php
  $row = 1; 
  if (($handle = fopen("localhost/data/htdocs/magento/var/import/Price.csv", "r")) !== FALSE) 
  {     
      while (($data = fgetcsv($handle, 8000, ",")) !== FALSE) 
      {         
          $num = count($data);         
          echo "&lt;p&gt; $num fields in line $row: &lt;br /&gt;&lt;/p&gt;\n";           
          for ($c=0; $c &lt; $num; $c++) 
          {             
              $temp = $data;             
              $string = implode(";", $temp);           
          }
              $pieces = explode(";", $string);             
              $col1 = $pieces[0];  
              $col2 = $pieces[1];
              $col3 = $pieces[2];      
              $col4 = $pieces[3];             
  
              $db_name = "magento";
                          $con = mysql_connect("localhost", "magento", "password");
                       If (!$con)
              {
                  die('Could not connect: ' . mysql_error());
                  mysql_close($con);
              }
              $seldb = mysql_select_db($db_name, $con);
  
              $query_fetch = "SELECT `sku` from `imoprt_prices`";
              $result_fetch = mysql_query($query_fetch);
              $num_rows = mysql_num_rows($result_fetch); 
  
              for($i = 0; $i &lt; $num_rows; $i++) 
              { 
                  $value = mysql_result($result_fetch, i, 'sku');
                  if(strcmp('".$value."', '".$col2."') == 0)
                  {               
                      $flag = 1;
                      break;
                  }
                  else
                  {
                      $flag = 0;
                          break;
                  }
              }
                  if($flag == 1)
                  {
                      $query_upadte = "(UPDATE imoprt_prices SET customer_id= '".$col1."', sku ='".$col2."', price= '".$col3."', website= '".$col4."'
                      )";
                      mysql_query($query_upadte);
                          $row++;         
                  }
                  if($flag == 0)
                  {
                      mysql_query("INSERT INTO `imoprt_prices`(`customer_id`,`sku`,`price`,`website`) VALUES('".$col1."','".$col2."','".$col3."','".$col4."')");
                      $row++;   
                  } 
  
      } 
  } 
  ?&gt;
  </code></pre>