Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Right, Antonio Laguna is right, but from what I can tell what you need to use is ajax:</p> <p><a href="http://api.jquery.com/jQuery.ajax/" rel="nofollow">http://api.jquery.com/jQuery.ajax/</a></p> <p>You'll have to create a textbox and use the onkeyup event to launch an ajax request, every time the user types a key, to display a php file with the given output from the database (in this file would be the code you had in your question above).</p> <p>This would look something like this:</p> <p><strong>index.html:</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function typing(search){ $.ajax({ url: 'get_db.php?q='+search, success: function(data) { $('#result').html(data); } }); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input type="textbox" onkeyup="javascript: typing(this.value);"&gt; &lt;div id="results" style="width: 200px; height: 300px;"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><strong>get_db.php:</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;ul&gt; &lt;?php $typed = $_GET["q"]; $typed = trim($typed); $query="select * from movies where name = '%typed%'"; $rt=mysql_query($query); echo mysql_error(); while($nt=mysql_fetch_array($rt)){ ?&gt; &lt;li&gt; &lt;a href="&lt;?php echo "$nt[link]"; ?&gt;"&gt;&lt;?php echo "$nt[name]"; ?&gt;&lt;/a&gt; &lt;/li&gt; &lt;?php } ?&gt; ?&gt; &lt;/ul&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload