使用PHP进行Spotlight搜索 [英] Spotlight search with PHP

查看:87
本文介绍了使用PHP进行Spotlight搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加一个聚光灯搜索功能-在每次键入事件发生变化的下拉菜单中以缩略图等丰富内容显示搜索结果-就像apple.com搜索一样-在网站上使用MySQL InnoDB中的数据桌子.因此,基本上,这是根据已输入的查询部分显示搜索结果(因此不能自动完成).

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.

由于它似乎很受欢迎,所以我猜想有一些PHP搜索引擎项目(最好是开源的并具有内存缓存支持),可以在定期导出相关数据的基础上将其集成到现有系统中.工作中的数据库/表.

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?

谢谢

推荐答案

这将是AJAX的工作.在以下位置查看JQuery的实现: http://api.jquery.com/category/ajax/

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

创建一个PHP脚本,以显示您的结果,就像有人键入结果并单击搜索"按钮一样. 然后,使用对该脚本的ajax调用并替换(或适当的HTML标记)的innerHTML

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)

类似这样的东西:

hello.php

hello.php

<?php   echo "Hello World"; ?>

index.html

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>

其中hello.php是您设置的页面,具有漂亮的结果.

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

这篇关于使用PHP进行Spotlight搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆