类似中关村在线,或者太平洋汽车 多属性搜索是怎么做的,怎样的思路
多属性搜索
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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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











In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.
