Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're loading <em>all</em> results initially, then could you not just store this in a JavaScript array and filter the results with JavaScript? This would save you a HTTP request on every key press, which can only be good for speed and resource usage of your site.</p> <p>EDIT: Sample.</p> <pre><code>&lt;?php $sql = "SELECT `title` FROM `your_table`"; $res = mysql_query($sql); $rows = array(); while ($row = mysql_fetch_assoc($res)) { $rows[] = $row['title']; } echo '&lt;script&gt;var data = ' . json_encode($rows) . ';&lt;/script&gt;'; ?&gt; &lt;form method="post" action=""&gt; &lt;fieldset&gt; &lt;input type="text" name="search" id="faq_search_input" /&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;script&gt; // I presume you're using jQuery var searchInput = $('#faq_search_input'); var searchResults = $('#searchresultdata'); var tmpArray = data; // add all results to results div $.each(data, function(key, val) { searchResults.append('&lt;li&gt;' + val + '&lt;/li&gt;'); }); searchInput.attr('placeholder', 'Begin typing to search'); searchInput.keyup(function() { // hide any &lt;li&gt; in your #searchresultdata that don't match input }); &lt;/script&gt; </code></pre> <p>I don't know what is in your <code>serverresponse</code> variable, so I can only guess what gets put into the <code>searchresultdata</code> <code>&lt;div&gt;</code>. You'll also need to modify the SQL query to match your table and column names.</p> <p><strong>Contents of searchdata.php</strong></p> <pre><code>$query = "SELECT Image, Manufacturer, Model FROM Device_tbl WHERE Manufacturer LIKE '%$keyword%' OR Model LIKE '%$keyword%'"; if ($keyword=='*') $query = "SELECT Image, Manufacturer, Model FROM Device_tbl"; $result=mysql_query($query, $database_connection) or die(mysql_error()); if($result){ if(mysql_affected_rows($database_connection)!=0){ while($row = mysql_fetch_object($result)){ ?&gt; &lt;div class="hold-cont"&gt; &lt;div class="holder"&gt; &lt;div class="image-hold" &gt; &lt;img class="image-icon" src="&lt;? echo $deviceimg.($row-&gt;Image); ?&gt;"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="device-name devicename-txt"&gt;&lt;? echo($row-&gt;Manufacturer. ' ' .$row-&gt;Model); ?&gt;&lt;/div&gt; &lt;/div&gt; &lt;? } }else { echo 'No Results for :"'.$_GET['keyword'].'"'; } } }else { echo 'Parameter Missing'; } </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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