title: list through file using a while loop
body: <p>I cannot get this to work properly, I need the program to list through the records within the file, if $records[$row][2]is the same as the previous, it should repeat class 'field' with a new $records[$row][2], otherwise it should start a new #row.  Please help!</p>
  
  <pre><code>if (($handle = fopen('upload/ATLANTA.csv', "r")) !== FALSE) {
  
  
      $prevRow2 = '';
  
      while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
          $num = count($data);
  
          $records[] = $data;
  
          echo 'Previous'. $prevRow2;
          echo "&lt;div id=\"row\"&gt;&lt;div id=\"num\"&gt;" .$row. "&lt;/div&gt;";
  
          if ($records[$row][2] == $prevRow2) {
  
              for ($c=0; $c &lt; $num; $c++) {
              if ($c != 1) {  
                  echo "&lt;div class=\"field\"&gt;" . $data[$c] . "&lt;/div&gt;";
                  }   
              }
              $prevRow2 = $records[$row][2];
              $row++;
          }
          else {
              echo "&lt;div id=\"row\"&gt;&lt;div id=\"num\"&gt;" .$row. "&lt;/div&gt;";
              for ($c=0; $c &lt; $num; $c++) {
              if ($c != 1) {  
                  echo "&lt;div class=\"field\"&gt;" . $data[$c] . "&lt;/div&gt;";
                  }   
              }
              $prevRow2 = $records[$row][2];
              $row++;
              echo "&lt;/div&gt;";
          }
  
  
  
  
      echo "&lt;/div&gt;";
  }
  fclose($handle);
  </code></pre>
  
  <p>}  </p>