title: php - Compare name files in directory with sql row
body: <p>I am trying to create a script that compare the names of the files in a directory with a row in my database in order to get all the files that are not present in the database list.</p>
  
  <p>The script I have so far prints out the files in the directory however when I try to compare the values with my sql I  have a lot of results repeated.</p>
  
  <p>How can I compare the name of the files in order to get all the name files that are not listed in my database?</p>
  
  <p>Directory:</p>
  
  <pre><code>a.mp4
  0.mp4
  b.mp4
  34.mp4
  c.mp4
  </code></pre>
  
  <p>Database rows:</p>
  
  <pre><code>&gt; Date---------------Name---------------video_path
  &gt; 01-01-01----------|jonh--------------|a.mp4
  &gt; 02-01-01----------|andrea------------|b.mp4
  &gt; 03-01-01----------|faith-------------|c.mp4
  </code></pre>
  
  <p>result should be:</p>
  
  <pre><code> 0.mp4
   34.mp4
  </code></pre>
  
  <p>SCRIPT:</p>
  
  <pre><code>$directory = '/var/www/html/EXAMPLE/resources/';
  
  $files1 = scandir($directory, 1);
  
  if ( $files1 !== false )
  {
      //$filecount = count( $files );
  
      foreach ($files1 as $i =&gt; $value) {
  
              $sqlfindTmp = "SELECT * FROM `videos`";
  
              if ($resultTmp = mysqli_query($conn,$sqlfindTmp)) {
  
                      while ($row=mysqli_fetch_row($resultTmp)) {
  
                            if ($row[3] == $value) {
  
  
                            }else{
  
                               echo $value . "&lt;br/&gt;";
                           }
                      }
              }   
  
          }
      }
  
  else
  {
      echo 0;
  }
  </code></pre>