title: PHP MySQL Search Function with one textbox
body: <p>What I'm trying to do currently is have a search function on my site that will look into a local MySQL db, in 1 column. The issue is the end-user could paste 1 item or they could paste 50 for example. And, without creating 50 textbox's I was wondering if it would be possible to make say a large textbox, that would search for a new field based on a space between them, or linebreak. Currently I have two search boxes, one where data is pasted, and the second null(I have null because when I left it blank it search for all(*).</p>
  
  <p><strong>Here is my page.</strong></p>
  
  <pre><code>form action="" method="get"&gt;  
  Paste your ZZZs here: &lt;br&gt;
  &lt;input type="text" name="item" id="textbox" maxlength="10" size="10"&gt;&lt;br&gt;
  &lt;input type="text" name="item2" id="textbox2" value="null" maxlength="10" size="10"&gt;&lt;script&gt;document.getElementById('textbox').focus()&lt;/script&gt;&lt;br /&gt;  
  &lt;input type="submit" value="Submit"/&gt;  
  &lt;/form&gt;  
  &lt;?php
  if (!empty($_REQUEST['item'])) {
  
      $item = mysql_real_escape_string($_REQUEST['item']);
      $item2 = mysql_real_escape_string($_REQUEST['item2']);     
  
      $sql = "select fcsku, fnsku from oak3_zzz_to_boo WHERE fcsku like '%".$item."%' or fcsku like '%".$item2."%'"; 
      $r_query = mysql_query($sql); 
  
      echo "&lt;table border=1&gt;";
      echo "&lt;tr&gt;&lt;td&gt;&lt;b&gt;FcSKU&lt;/td&gt;&lt;td&gt;&lt;b&gt;FnSKU&lt;/td&gt;&lt;/tr&gt;";
      while ($row = mysql_fetch_array($r_query)) { 
          echo "&lt;tr&gt;&lt;td&gt;".$row['fcsku']."&lt;/td&gt;&lt;td&gt;".$row['fnsku']."&lt;/td&gt;&lt;/tr&gt;"; 
      }  
  }
  echo "&lt;/table&gt;";
  mysql_close();
  </code></pre>
  
  <p>My Table structure only has 2 columns, FnSKU, and FcSKU</p>
  
  <p><strong>Thanks to the contributors here is the working code!</strong></p>
  
  <pre><code>&lt;form action="" method="get"&gt;  
  Paste your ZZZs here: &lt;br&gt;
  &lt;textarea name="item" id="textbox"&gt;&lt;/textarea&gt;
  &lt;script&gt;document.getElementById('textbox').focus()&lt;/script&gt;&lt;br /&gt;  
  &lt;input type="submit" value="Submit"/&gt;  
  &lt;/form&gt;  
  &lt;?php
  if (!empty($_REQUEST['item'])) {
  
      $search = "\"" . strip_tags(preg_replace("/[\n\r ]/","\", \"",$_REQUEST["item"])) . "\""; // for space as delimiter 
      ##$search = "\"" . strip_tags(str_replace(" ","\", \"",$_REQUEST["item"])) . "\""; // for space as delimiter 
  
      $query = "SELECT fcsku, fnsku FROM oak3_zzz_to_boo WHERE fcsku IN ($search)";
      $r_query = mysql_query($query); 
  
      echo "&lt;table border=1&gt;";
      echo "&lt;tr&gt;&lt;td&gt;&lt;b&gt;FcSKU&lt;/td&gt;&lt;td&gt;&lt;b&gt;FnSKU&lt;/td&gt;&lt;/tr&gt;";
      while ($row = mysql_fetch_array($r_query)){ 
          echo "&lt;tr&gt;&lt;td&gt;".$row['fcsku']."&lt;/td&gt;&lt;td&gt;".$row['fnsku']."&lt;/td&gt;&lt;/tr&gt;"; 
      }  
  }
  echo "&lt;/table&gt;";
  mysql_close();
  </code></pre>