Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this JQuery search I recently coded.. (To use this you must include the JQuery-Library in your )</p> <p><strong>HTML:</strong></p> <pre><code>&lt;form name="searchform" action="" method="post" onsubmit=""&gt; &lt;input type="text" name="q" class="inputTextSearchBox" id="livesearch" onkeyup="searchIt()" onblur="if (this.value == '') {this.value = 'Search..';}" onfocus="if(this.value == 'Search..') {this.value = '';}" value="Search.." onKeyPress="return disableEnterKey(event)" /&gt; &lt;/form&gt; &lt;div id="LSResult" style="display: none;"&gt;&lt;/div&gt; </code></pre> <p><strong>CSS (example):</strong></p> <pre><code>#LSResult { background-color: #FFFFFF; border: 1px solid #e9e9e9; padding: 20px 5px 5px; position: absolute; width: 250px; z-index: 98; -webkit-border-radius: 6px 0 6px 6px /*{cornerRadius}*/; -moz-border-radius: 6px 0 6px 6px /*{cornerRadius}*/; border-radius: 6px 0 6px 6px /*{cornerRadius}*/; -khtml-border-radius: 6px 0 6px 6px /*{cornerRadius}*/; -webkit-box-shadow: 2px 3px 2px #888; -moz-box-shadow: 2px 3px 2px #888; box-shadow: 2px 3px 2px #888; } </code></pre> <p><strong>JQuery</strong></p> <pre><code>function searchIt() { var inputValue = $('#livesearch').delay(100).val(); var linkResult = "livesearch.php?q=" + encodeURIComponent(inputValue); if((inputValue != '')&amp;&amp;(inputValue != ' ')){ $('#LSShadow').load(linkResult); $('#LSResult').show(100); } else { $('#LSShadow').load(linkResult); $('#LSResult').hide(100); } } // Disabling form submition by enter key function disableEnterKey(e) { var key; if(window.event) key = window.event.keyCode; //IE else key = e.which; //firefox if(key == 13) return false; else return true; } </code></pre> <p><strong>PHP</strong> (Livesearch.php)</p> <pre><code>if(isset($_REQUEST['q'])) { $q = $_REQUEST['q']; $q = trim(urldecode($q)); $q = ereg_replace("([ ]+)", "%",$q); // Your SQL $sql2 = "SELECT DISTINCT * FROM table WHERE "; $sql2 .= "Field LIKE '%$q%'"; $sql2 .= " ORDER BY Field"; $sq2 = mysql_query($sql2); $st2 = mysql_num_rows($sq2); print "&lt;?xml version='1.0' encoding='utf-8' ?&gt;"; if($st2&gt;=1) { while($a = mysql_fetch_array($sq2)) { print your Results in list form } } } else { print "&lt;table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"&gt;&lt;tr&gt;&lt;td width=\"250px\"&gt;&lt;h4&gt;No result..&lt;/h4&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"; } } </code></pre> <p>If you need a search tag highlighting code example, please let me know.</p>
    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.
    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