高级搜索页面上的实时 MySQL 搜索结果

发布于 2024-08-31 16:08:38 字数 863 浏览 1 评论 0原文

我是一名业余爱好者,去年九月开始学习 PHP,只是为了建立一个我一直希望和梦想另一个更有能力的人可以制作的业余爱好网站。

我喜欢编程,但我的空闲时间很少,并且喜欢广泛的其他兴趣和活动。

我觉得仅学习 PHP 就可以让我为我的网站创建 98% 的所需功能,但最后 2% 非常有吸引力:

该网站最强大的工具是一个高级搜索页面,可以从 1000 多个记录游戏中进行选择场景数据库。用户可以进行极其深入的数据挖掘——这个高级页面有超过 50 个不同的潜在变量。它的设计目的是允许铁杆用户搜索我们数据库中几乎任何可能的数据组合,并且效果很好。那些对浏览众多选项不感兴趣的人可以使用基本搜索,它由高级搜索中最受欢迎的部分组成。

由于高级搜索非常全面,并且数据库相当小(最大潜在命中数不到 1,200 个),因此您选择包含的每个变量获得任何合格结果的可能性都会急剧下降。

在我的幻想世界中,我可以像使用 Excalibur 一样使用 AJAX,当我的用户使用此页面时,他们的屏幕一角会有一个实时总结果计数器,该计数器会自动更新其查询结构并报告添加每个变量后将显示多少个结果。通过这种方式,可以毫不费力地知道有多少变量就足够了,以及何时添加一个变量将结果集清零。

在 IBuyPower.com 上构建新的自定义计算机时,一个有点类似的实现(至少在视觉上)是 Subtotal 侧边栏

对于那些实际上仍在阅读本文的人,我的问题实际上相当简单:

考虑到时间&如上所述,我是否能够学习足够的 AJAX(或其他内容)来实现这一功能,而不会遇到太多麻烦?我是否能够或多或少地插入预先编写的代码片段并进行调整以适应?或者我应该考虑将我的代码开放给值得信赖的人吗?未来有能力执行此实施的个人吗? (假设我能找到一个......)

谢谢。

I'm a hobbyist, and started learning PHP last September solely to build a hobby website that I had always wished and dreamed another more competent person might make.

I enjoy programming, but I have little free time and enjoy a wide range of other interests and activities.

I feel learning PHP alone can probably allow me to create 98% of the desired features for my site, but that last 2% is awfully appealing:

The most powerful tool of the site is an advanced search page that picks through a 1000+ record game scenario database. Users can data-mine to tremendous depths - this advanced page has upwards of 50 different potential variables. It's designed to allow the hardcore user to search on almost any possible combination of data in our database and it works well. Those who aren't interested in wading through the sea of options may use the Basic Search, which is comprised of the most popular parts of the Advanced search.

Because the advanced search is so comprehensive, and because the database is rather small (less than 1,200 potential hits maximum), with each variable you choose to include the likelihood of getting any qualifying results at all drops dramatically.

In my fantasy land where I can wield AJAX as if it were Excalibur, my users would have a realtime Total Results counter in the corner of their screen as they used this page, which would automatically update its query structure and report how many results will be displayed with the addition of each variable. In this way it would be effortless to know just how many variables are enough, and when you've gone and added one that zeroes out the results set.

A somewhat similar implementation, at least visually, would be the Subtotal sidebar when building a new custom computer on IBuyPower.com

For those of you actually still reading this, my question is really rather simple:

Given the time & ability constraints outlined above, would I be able to learn just enough AJAX (or whatever) needed to pull this one feature off without too much trouble? would I be able to more or less drop-in a pre-written code snippet and tweak to fit? or should I consider opening my code up to a trusted & capable individual in the future for this implementation? (assuming I can find one...)

Thank you.

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

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

发布评论

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

评论(2

山人契 2024-09-07 16:08:38

对于初学者来说,这是一个很棒的项目。

首先我会说考虑使用像 jquery (jquery.com) 这样的库。它将简化其中的 javascript 部分,并且手册非常好。

您想要做的事情可以分为几个步骤:

  1. 用户更改了
    高级搜索页面。
  2. 用户的
    浏览器收集所有字段
    值并将它们发送回
    服务器。
  3. 服务器执行一个
    使用值进行搜索并返回
    结果数
  4. 用户的
    浏览器收到的数量
    结果并更新显示。

现在介绍实现细节:

  1. 这可以通过 onchange 和 onfocus 等 JavaScript 事件来完成。
  2. 您可以将字段值收集到 JavaScript 对象中,将该对象序列化为 json 并使用 ajax 将其发送到服务器上的 php 页面。
  3. 服务器页面(在 php 中)将读取 json 对象并使用数据进行搜索,然后将结果作为标记或文本发送回。
  4. 然后您可以直接在浏览器中显示结果。

这可能看起来需要理解很多,但您可以进一步分解每个步骤并一点一点地了解细节。

This is a great project for a beginner to tackle.

First I'd say look into using a library like jquery (jquery.com). It will simplify the javascript part of this and the manual is very good.

What you're looking to do can be broken down into a few steps:

  1. The user changes a field on the
    advanced search page.
  2. The user's
    browser collects all the field
    values and sends them back to the
    server.
  3. The server performs a
    search with the values and returns
    the number of results
  4. The user's
    browser receives the number of
    results and updates the display.

Now for implementation details:

  1. This can be accomplished with javascript events such as onchange and onfocus.
  2. You could collect the field values into a javascript object, serialize the object to json and send it using ajax to a php page on your server.
  3. The server page (in php) will read the json object and use the data to search, then send back the result as markup or text.
  4. You can then display the result directly in the browser.

This may seem like a lot to take in but you can break each step down further and learn about the details bit by bit.

冷夜 2024-09-07 16:08:38

在不知道您的专业水平的情况下很难回答您的问题,但请查看 AJAX 的简短描述: http://blog.coderlab.us/rasmus-30-second-ajax-tutorial

如果这有意义,那么您的功能可能“无需太多麻烦”就可以实现。如果它看起来难以理解,那么可能不是。

Hard to answer your question without knowing your level of expertise, but check out this short description of AJAX: http://blog.coderlab.us/rasmus-30-second-ajax-tutorial

If this makes some sense then your feature may be within reach "without too much trouble". If it seems impenetrable, then probably not.

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