用户进行的最近5次搜索 [英] last 5 searches done by the user

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

问题描述

朋友,
我正在一个网站上工作,用户可以在其中搜索数据库中存在的主题.现在我想向用户展示用户在注销时进行的最后5次搜索. /> 谢谢.

Hi Friends,
I am working with a website, in which the users can search for topics present in the database.Now i want to show the users, the last 5 searches done by the user on log out.How can i implement that...
Thank you.

推荐答案

Cookie是最简单的方法.
每次进行搜索时,检索现有的cookie,如果已经有五个,则删除最旧的cookie,然后将新的serach添加到cookie列表中.然后将其保存回去.
MSDN:如何编写Cookie [
Cookies are the easiest way.
Each time teh do a search, retrieve the existing cookie, remove the oldest if there are five already, and add teh new serach to teh cookies list. Then save that back.
MSDN: How to write a cookie[^]


我们可以为此使用分析.发现它是解决实现此功能的最简单,最佳方法.
we can using profiling for this purpose.Its found to be the simplest and most optimum way to solve implement this function.


您需要做的是保留最近5次搜索.

要保留数据,您可以使用
1. Cookie(客户端)
2.会话(服务器端)
3.存储到数据库

在上述3个选项中,如果搜索字符串的长度不是很大,我宁愿将数据存储在cookie中.

您可以使用分隔符创建一个字符串,就像这样
搜索1;搜索2;搜索3 .....
并将字符串存储在cookie中.

在获取字符串的同时,阅读cookie并将其显示在您希望显示的任何位置.

希望这会有所帮助.
欢呼
What you need to do is to persist the last 5 searches.

To persist data you can use
1. cookie (client side)
2. session (server side)
3. storing to database

Among the above 3 options, I would prefer storing data in cookie provided the search string length is not so big.

You can create a string with a delimiter, some thing like this
search 1;search 2;search 3.....
and store the string in cookie.

While getting the string, read the cookie and show it wherever you want it to show.

Hope this helps.
cheers


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

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