对我来说对一组数据执行搜索的最简单方法是什么

发布于 2024-11-18 11:11:09 字数 592 浏览 3 评论 0原文

我们有一组数据(只是地名),但数量超过 25k+。有人问我是否有一种方法(总是有)搜索这些数据,然后根据用户输入从该数据返回一个值。

现在我的技能确实在于 XHTML 和 CSS,我可以涉足 JSP 和 JQuery,但我不确定最好的方法。我们能否:

  1. 将数据存储在 Access 数据库中,然后编写查询以根据用户输入选择值?然后需要将该输出显示在网页上。这需要用什么语言来完成?

  2. 我发现了一个 JQuery 'Quicksearch' 插件,我认为它非常好(http://lomalogue .com/jquery/quicksearch/super_table.html)

现在我喜欢这个主意2),因为它是在 JQuery 中完成的,但我认为对于这种大小的数据来说这是不可行的,尤其是因为页面会很大(尽管我假设某些数据可能被隐藏)。有更简单的方法吗?我错过了什么吗?

感谢这可能被认为含糊不清,所以很抱歉,但我不知道最好的方法是什么。

谢谢

We have a set of data (just names of places) but there are in excess of 25k+. I have been asked if there is a way (there always is), of searching this data and then returning a value from this data based on user input.

Now my skills really lie in XHTML and CSS and I can dabble in JSP and JQuery but I'm not sure of the best approach for this. Could we:

  1. Store the data in an access database and then write a query to select a value based on user input? This output would then need to be displayed on a webpage. What language would this need to be done in though?

  2. I have found a JQuery 'Quicksearch' plugin which I think is excellent (http://lomalogue.com/jquery/quicksearch/super_table.html)

Now I like the idea of 2) as it's done in JQuery but I don't think it's feasible for this size of data, especially not as the page would be HUGE (though I assume some of the data could be hidden). Is there an easier approach? Am I missing something?

Appreciate that this could be deemed vague so apologies but I don't know what the best approach would be.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

╄→承喏 2024-11-25 11:11:09

根据我对您正在从事的项目的了解,最好将数据划分为(可能基于地理的)块。也许按州/省或按地点类型。然后,您可以设计简单的 SQL 查询,根据此排序标准从数据库中提取长位置列表。这些将允许您将可管理的数据量拉入页面。返回的数据块可以基于访问者的地理位置或基于用户输入(“选择区域”)。该数据可以通过 AJAX 移动到页面: http://api.jquery.com/jQuery.ajax /

我设想访问者选择一个区域。这样做会触发 AJAX 请求,该请求发送到 PHP 脚本,该脚本在 SQL 查询中使用该“区域”,该查询将该区域中的所有地名返回给 PHP 脚本。脚本完成后,AJAX 请求(将耐心等待脚本完成)将抓取所有 HTML 数据并将其拉回页面。然后由页面上的 jQuery 将其格式化为表格,然后 QuickSearch 就会发挥它的魔力。

或者,您可以让 PHP 以 JSON 形式返回数据,这将使数据在返回页面后更易于管理。然而,这需要熟悉 JSON 以及如何在 jQuery/javascript 中使用它。

From what little I know of the project you are working on, it seems best to divide the data into (perhaps geographically-based) chunks. By state/province or by types of places, perhaps. You could then devise simple SQL Queries to pull out long lists of places from the database based on this sorting criteria. These would allow you to pull manageable amounts of data into the page. Which chunk of data is returned could be based on the visitors geo-location or based on user input ('Select a region'). This data could be moved to the page via AJAX: http://api.jquery.com/jQuery.ajax/

I envision the visitor selecting a region. Doing so triggers the AJAX request, which sends to a PHP script which uses that 'region' in an SQL Query, which returns all place names in that region to the PHP script. Once the script is done, the AJAX request (which will wait patiently for the script to finish) will grab all that data as HTML and pull it back to the page. It would then be up to jQuery on the page to format this into a table and then QuickSearch does it's magic.

Alternately, you can have PHP return the data as JSON, which would make the data much more manageable once it's back on the page. This, however, would require a familiarity with JSON and how to use it in jQuery/javascript.

涫野音 2024-11-25 11:11:09

如果可以的话,最好在服务器端完成此操作,在这种情况下,您应该将数据存储到数据库中。您将使用 SQL 语句从数据库中查询条目(学习基本 SQL 并不难)。 SQL 语句将嵌入到您使用的服务器端脚本语言(PHP、JSP 等)中。只需查看您所用语言的文档,了解如何访问数据库即可。

在网页中存储/隐藏数据,然后使用Javascript/JQuery进行搜索会非常慢(至少10秒左右)。这是可行的,而且并不是特别困难,但对于大多数应用程序来说,这种迟缓是不可接受的。

If it's ok, it would be best to have this done server-side in which case you should store your data into a database. You'll use SQL statements to query entries from the database (it's not that hard to learn basic SQL). The SQL statements will embedded in whichever server-side scripting language you're using (PHP, JSP, etc). Just look in your language's documentation at how to access databases.

Storing/hiding the data in the web page and then searching it using Javascript/JQuery will be very slow (at least 10 seconds or so). It's do-able and not particularly difficult, but for most applications that kind of sluggishness is not acceptable.

心碎无痕… 2024-11-25 11:11:09

tskuzzy 是对的,但遗漏了一个关键点 - 这就是 AJAX 非常适合的类型。您可以将数据存储在数据库中,并在服务器端检索它。您可以使用 AJAX 来回传递用户值,并从服务器获取响应,然后使用 jquery/javascript 在结果传入时显示结果。这样,您就不会出现持续不断的页面加载。

tskuzzy is right, but left out a crucial bit - this is the type of thing that AJAX works really nicely for. You can store the data in the database, and retrieve it on the server side. You can use AJAX to pass the user value back and forth, and to get the response from the server, and then use jquery/javascript to display the results when they come in. That way, you wont have constant pageloads flying around.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文