views:

31

answers:

1

Hi. I want to add a spotlight search functionality - search results being displayed with rich contents like thumbnail etc in a drop down menu changing on each keyup event - just like the apple.com search - to a site, having data in MySQL InnoDB tables. So basically that is displaying search results based on the part of the query that has already been input (so not autocomplete).

The data is spread into separate tables for categories, help pages, blog pages and so on. The search script must take into account just a subset of columns.

Since it seems to be a popular demand, I guess there are some PHP search engine projects (preferably open-source and with memcached support), which could be integrated into the existing system on the basis of regular exports of relevant data from the working db/tables.

Are there any solutions out there? Which one would you recommend? Or maybe it would be better to implement it the other way around?

Thanks

+1  A: 

This would be a job for AJAX. Check out JQuery's implementation of it at: http://api.jquery.com/category/ajax/

Create a PHP script that displays your results as if someone typed them and clicked a button to 'search'. Then, use an ajax call to that scripts and replace the innerHTML of a (or appropriate HTML tag)

Something like this:

hello.php

<?php   echo "Hello World"; ?>

index.html

<html>
<head>
<script language="javascript">
  function update_results(){
    $.ajax({
     url: 'hello.php',
     success: function(data) {
       $('#results').html(data);
     }
    });
  }
</script>
</head>
<body>
  <label>Spotlight: <input id="q" type="text" onkeypress="update_results()" /></label>
  <div id="results"></div>
</body>
</html>

Where hello.php is the page you setup with your pretty results.

DBruns
Actually, no. I want do display not the autocompleted options, but rather the results of the search for the partly given keyword.
htf