title: Store an associative PHP array into the database without duplication
body: <p>I am trying to store an associative PHP array (a table) into the database.This a big array that contains many fields (around 30 fields) and I just want to store 6 fields of this array in to a table which has 6 fields as well. Each row on this array contains the information of a specific article. I want to make sure that each article will be stored only one time (no duplication) so before storing data I need to check database for repetitive queries. Here is my code which is not working properly. I would appreciate if someone help me with this.</p>
  
  <pre><code>&lt;?php $results = $PubMedAPI-&gt;query($term, false); ?&gt;
  &lt;?php if (!empty($results)): ?&gt;
  &lt;?php
      $con=mysqli_connect("localhost","root","","db");
      // Check connection
      if (mysqli_connect_errno())
      {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
      }
      foreach ($results as $result):
  
          $pmid = $result['pmid'];
          $title = $result['title'];
          $authors = $result['authors'];
          $journalabbrev = $result['journalabbrev'];
          $year = $result['year'];
          $abstract = $result['abstract'];
          $fetched_articles = mysqli_query($con,"SELECT pmid FROM articles");
  
          while( ($row = mysqli_fetch_array($fetched_articles))) {
              if ($row['pmid'] == $pmid) {
                  echo "This record has already been stored into the database!";
              } else {
                  mysqli_query($con,"INSERT INTO articles (pmid, title, authors, journalabbrev, year, abstract)
                  VALUES ('$pmid', '$title', '$authors', '$journalabbrev', '$year', '$abstract')");
                  echo "This record has been stored into the database!";
              }
          }
      endforeach;
      mysqli_close($con);
  ?&gt;
  &lt;?php endif; ?&gt;
  </code></pre>