Speed up live search js, php, mysql
<p>I have made a "live search bar" with php and javascript. if you enter a word in the search bar it searches the database (mysql).</p>

<p>index.php:</p>

<pre><code>&lt;input type="text" onkeyup="getMovie(this.value)"/&gt;
&lt;div id="movie"&gt;&lt;/div&gt;
</code></pre>

<p>javascript.js:</p>

<pre><code>function getMovie(value) {
$.post("getmovie.php",{partialMovie:value},function(data) {
    $("#movie").html(data);
});
}
</code></pre>

<p>getmovie.php:</p>

<pre><code>include_once "connection.php"; 

if($_POST['partialMovie']){
    $partialMovie = $_POST['partialMovie'];

    $sql = "SELECT title FROM movie WHERE title LIKE '%$partialMovie%'";
    $stm = $db-&gt;prepare($sql);
    $result = $stm-&gt;execute(array());
    while($row = $stm-&gt;fetch(PDO::FETCH_ASSOC)) {
        echo "&lt;li&gt;".$row['title']."&lt;/li&gt;";
    }
}
</code></pre>

<p>This works, but it is way to slow. I have only 3 "movies" in my database, but it takes like a second or two to show the results. </p>

<p>the titles of the 3 movies are: een twee drie.
but if i type "een" fast, after a second you see een, twee, drie. a second later you see: een twee. and another second later you see: een. </p>

<p>So my question is: is there a way to speed the search up or is there a way to stop searching if you type another letter?</p>
