我需要在php live search中添加条件的帮助 [英] I need help with adding condition to php live search

查看:71
本文介绍了我需要在php live search中添加条件的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在学习php,最终进入了本教程http://www.w3schools.com/php/php_ajax_livesearch.asp

I am just learning php and ended up at this tutorial http://www.w3schools.com/php/php_ajax_livesearch.asp

到现在,我的PHP搜索文件看起来与示例中的相同,但是我将if (strlen($q) > 0)更改为if (strlen($q) > 3)以在键入最少3个单词后显示结果.我想知道如果有很多结果该如何使结果分页?

Till now my PHP search file looks the same as in example but i changed the if (strlen($q) > 0) to if (strlen($q) > 3) to display results after typing minimum 3 words. I am wondering how can i make the results paginate if there are lots of them?

谢谢

Roshan

推荐答案

搜索建议的思想是向用户显示与您的查询相关的网站内容.话虽这么说,您只应该抛出结果的一个子集,即最相关的第一个结果,而不是整个文件或数据库.换句话说,您不需要分页.

The idea of search suggestions is to show the user what do you have in your site, in terms of relevance, that match his query. This being said, you should only throw a subset of results, being the first result the most relevant, instead of the whole file or database. In others words, you don't need pagination.

向用户显示5或10个项目,如果他在继续写直到找到它之前没有找到自己想要的东西.如果找不到,他将对其进行搜索.请记住,这只是一个建议.

Show the user 5 or 10 items, if he doesn't find what he's after he'll keep writing until he finds it. If he doesn't finds it he will just search it. Remember that it is a suggestion and nothing more.

这篇关于我需要在php live search中添加条件的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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