I have been using a nasty combination of php and mysql to generate a
narrow down by attribute bar as seen on the likes of shopping.com. For
example a user could select 4X Zoom to narrow down a selection of
digital cameras.
The current method I use is to loop though each one of the attributes
and their values and run a separate query of each attribute value:
for($i=0; $i < attribute_count ; $i++) {
for($j=0; $j < attribute_value _count; $j++) {
mysql_query("se lect count(*) from products, attributes where
<attribute conditions>");
}
}
The problem with this approach is that it is very slow. I would like to
be able to combine this code into one query. Is this possible?
Any ideas are appreciated, I have tried caching results with limited
success but would like a "clean" solution to this annoying problem.
narrow down by attribute bar as seen on the likes of shopping.com. For
example a user could select 4X Zoom to narrow down a selection of
digital cameras.
The current method I use is to loop though each one of the attributes
and their values and run a separate query of each attribute value:
for($i=0; $i < attribute_count ; $i++) {
for($j=0; $j < attribute_value _count; $j++) {
mysql_query("se lect count(*) from products, attributes where
<attribute conditions>");
}
}
The problem with this approach is that it is very slow. I would like to
be able to combine this code into one query. Is this possible?
Any ideas are appreciated, I have tried caching results with limited
success but would like a "clean" solution to this annoying problem.
Comment