类似中关村在线,或者太平洋汽车 多属性搜索是怎么做的,怎样的思路
多属性搜索
http://detail.zol.com.cn/notebook_index/subcate16_0_list_4000_s1227_1_1_0_1.html 中关村在线http://price.pcauto.com.cn/price/q-p2-k75.html 太平洋汽车
点击某项属性,没有产品的某些属性就会相应的变灰不可用状态,
感问 要实现这样的功能是怎样的思路,如何做。。。
分数不多见谅了,呵呵....
回复讨论(解决方案)
这个之前有人问过
两种方案:
1是用javascript根据选择的变量组合成一个url,这种方案需要先选择,点击一个按钮后打开网页(操作有点像提交)
2是php根据每种参数写一个链接,这种方案每点击一个参数就刷新网页,刷新网页时就把参照已经选择的多个条件把所有链接重新计算输出
2的变形方案是ajax
view-source:http://detail.zol.com.cn/notebook_index/subcate16_0_list_4000_s1227_1_1_0_1.html
<dt>品牌</dt> <dd class="brand-sel-box clearfix"> <div id="singular" class="brand-list"> <span class="all sel">不限</span> <a href="/notebook_index/subcate16_160_list_4000_s1227_1_1_0_1.html">联想</a> <a href="/notebook_index/subcate16_227_list_4000_s1227_1_1_0_1.html">华硕</a> <a class="null" rel="nofollow" href="/notebook_index/subcate16_21_list_4000_s1227_1_1_0_1.html">戴尔</a> <a class="null" rel="nofollow" href="/notebook_index/subcate16_223_list_4000_s1227_1_1_0_1.html">惠普</a> <a href="/notebook_index/subcate16_1191_list_4000_s1227_1_1_0_1.html">神舟</a> <a class="null" rel="nofollow" href="/notebook_index/subcate16_218_list_4000_s1227_1_1_0_1.html">Acer宏?</a>.....<dt>价格</dt> <dd class="clearfix"> <a href="/notebook_index/subcate16_list_s1227_1.html" class="all">不限</a> <a class="null" rel="nofollow" href="/notebook_index/subcate16_0_list_0_s1227_1_1_0_1.html">1999元以下</a> <a href="/notebook_index/subcate16_0_list_2000_s1227_1_1_0_1.html">2000-2499元</a> <a href="/notebook_index/subcate16_0_list_2500_s1227_1_1_0_1.html">2500-2999元</a>
view-source:http://price.pcauto.com.cn/price/q-p2-k75.html
<div class="getTh">价格:</div><div class="umLimit"><a class='' href="/price/q-k75.html">不限</a></div><div class="Items"><a class='' href="/price/q-p1-k75.html">5万以下</a><a class=' s' href="/price/q-p2-k75.html">5-8万</a><a class='' href="/price/q-p3-k75.html">8-10万</a><a class='' href="/price/q-p4-k75.html">10-15万</a><a class='' href="/price/q-p5-k75.html">15-20万</a><a class='' href="/price/q-p6-k75.html">20-25万</a>......<div class="getTh">级别:</div><div class="umLimit"><a class='' href="/price/q-p2.html">不限</a></div><div class="Items"><a class=' ' href='/price/q-p2-k76.html'>微型车</a><a class=' ' href='/price/q-p2-k110.html'>小型车</a><a class=' ' href='/price/q-p2-k73.html'>紧凑型车</a><a class=' ' href='/price/q-p2-k72.html'>中型车</a><a class=' null' href='javascript:void(0)'>中大型车</a>
同样也是如此
常用的思路还是后台整合在url里面输出到前台吧。
ajiax 后台处理数据
最简单方式ajax 获取数据输出
其实问题的关键还是:“怎么通过某一事物的单一属性,判断其他属性是否存在”;
如果是 每点一次条件,都会到数据库里取一遍的话,这实现起来不难,比如点了一下
“5-8万” 这个条件,最笨的方法无非就是在后台
select * from auto_detail where market_price >= 50000 and market_price (假设auto_detail是一个存储了所有厂商的所有车型的详细资料表)
返回的结果可能有几百条,再对结果循环一遍,分别一一将返回集里的auto_grade,car_brand....(略);都存入一个二维数组里。
那“所有汽车级别,汽车品牌。。”等等这些数据哪来呢?无非再select distinct auto_grade from xxx 而已。
做好点的话把所有这种供对比的,不必经常更新的数据放缓存里面,就不用每次都去数据库查一遍了。
然后就简单了,分别判断一下,auto_grade里那些属性是有的,那些属性是没有的,再返回一个数组给jQuery,控制页面把样式改了就可以了。
以上是最笨的做法,权当抛砖引玉
这个是专用企业级搜索引擎!
查solr, sphix 和lucene!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...

The article discusses adding custom functionality to frameworks, focusing on understanding architecture, identifying extension points, and best practices for integration and debugging.

An official introduction to the non-blocking feature of ReactPHP in-depth interpretation of ReactPHP's non-blocking feature has aroused many developers' questions: "ReactPHPisnon-blockingbydefault...
