title: SQL query and preg_match
body: <p>Need your help with sql query and php.</p>
  
  <p>I have to pieces of code here:<br>
  1.  </p>
  
  <pre><code>$sql = "SELECT SUBSTR(n.`title`, 1,1) FROM node n WHERE n.`type` = 'type1'";
  $results = db_query($sql);
  while ($fields = db_fetch_array($results)) {
    foreach($fields as $key =&gt; $value) {
      echo $value;
    }
  }
  </code></pre>
  
  <p>The code above returns first letters of my article titles (table - node, columns - type, title) like this - NHDKFLF...  </p>
  
  <p>2.</p>
  
  <pre><code>if (preg_match ('/A/i', $string)) {
    echo ('Contains letter A'); //
  }
  else {
    echo ('Nothing'); //
  }    
  </code></pre>
  
  <p>And the second part checks if the string contains certain letters. </p>
  
  <p>Now, the question is how to combine these two pieces of code? I mean how to pull data from DB and check if it has certain letters.</p>
  
  <p>Thanks in advance.</p>