Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $key=$_GET['key'];
- $search_results_array = array();
- $sql = "SELECT * FROM `Product_Data` WHERE `Product_Name` LIKE '%{$key}%' OR `Product_Tags` LIKE '%{$key}%' ORDER BY `Product_Sequence` ASC";
- $q = $db->query($sql);
- if (PEAR::isError($q)) {
- showError ($q);
- exit;
- }
- $numRows = $q->numRows();
- while ($row = $q->fetchRow()) {
- $product_name = $row['Product_Name'];
- $product_id = $row['Product_ID'];
- $search_results_array[] = "<a href='/index.php?page=purchase&product_id=$product_id' class='livesearch_link'>$product_name</a>";
- }
- print json_encode($search_results_array);
- <div class=".col-md-6">
- <div class="panel panel-default">
- <div class="bs-example">
- <input type="text" name="typeahead" class="typeahead tt-query" autocomplete="off" spellcheck="false" placeholder="Search">
- </div>
- <script>
- $(document).ready(function(){
- $('input.typeahead').typeahead({
- name: 'typeahead',
- remote: '/manage/process_ajax_search.php?key=%QUERY',
- limit : 10,
- });
- });
- $(document).on('click','.tt-suggestion .livesearch_link',function(e){
- e.preventDefault();
- var href = $(this).attr('href');
- window.location.replace(href);
- return false;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement