title: search all the elements of array of strings in mysql using php
body: <p>I need to search all elements of an array of strings of the database and to return how many values are matched to the existing database entries..</p>
  
  <p>database name = words , table name=collection , word is the coloumn in which array to bi searched</p>
  
  <pre><code>&lt;?php
  $array=array('abc','xyz','lmn','pqr');
  @ $db=new mysqli('localhost','root','','words');
  
  if(mysqli_connect_errno()) {
      echo 'Error:Could not connect to the database';
  } else echo 'connected';
  
  $db-&gt;select_db('words');
  
  foreach($array as $s) {
      $query="select * from collection where word = '%".$s."%'";
      $result=$db-&gt;query($query);
  }
  
  if($result) echo $db-&gt;affected_rows;
  $db-&gt;close();
  ?&gt;
  </code></pre>