title: PHP: mysql query "WHERE first 3 (or 4,5,6 depending on length of string) characters = '$string'"
body: <p>I am doing a ajax suggestion function</p>
  
  <p>The user gives an input of a word (like ICE), then the ajax script passes this to a .php script and that script looks it up in the database and should suggest the word ICECREAM.</p>
  
  <p>This is where I am stuck. I need a query which goes like this:</p>
  
  <pre><code>SELECT * FROM table WHERE first str_len($string) characters = $string
  </code></pre>
  
  <p>Could you help me out please?</p>