View Single Post
  #6  
Old 03-29-2003, 11:00 PM
  kangus's Avatar 
kangus kangus is offline
 

Senior Member
  
Join Date: Feb 2003
Posts: 160
 

Default Just get it done

Had to get a site up and data imported:
ALTER TABLE `xcart_products` ADD `categoryid4` INT DEFAULT '0' NOT NULL AFTER `categoryid3` ,
ADD `categoryid5` INT DEFAULT '0' NOT NULL AFTER `categoryid4` ,
ADD `categoryid6` INT DEFAULT '0' NOT NULL AFTER `categoryid5` ,
ADD `categoryid7` INT DEFAULT '0' NOT NULL AFTER `categoryid6` ;

//line 61 in customer/products.php
$search_query = "($sql_tbl[products].categoryid='$cat' or $sql_tbl[products].categoryid1='$cat' or $sql_tbl[products].categoryid2='$cat' or $sql_tbl[products].categoryid3='$cat' or $sql_tbl[products].categoryid4='$cat' or $sql_tbl[products].categoryid5='$cat' or $sql_tbl[products].categoryid6='$cat' or $sql_tbl[products].categoryid7='$cat') and $sql_tbl[products].forsale='Y'";

The categoryid should not be in the product table, there should be a relation table with a productid joined to a categoryid that way we would have unlimited product placement and lose (in this case) 7 OR's which really SUCK.

In case your interested, the complete select: 6 AND, 6 OR and a group function, if you add the other four categories that makes it 10 OR's

select xcart_products.*, xcart_categories.category,
min(xcart_pricing.price) as price
from xcart_products, xcart_pricing, xcart_categories
where xcart_pricing.productid=xcart_products.productid
and xcart_pricing.quantity=1
and xcart_products.categoryid=xcart_categories.categor yid
AND (xcart_categories.membership=''
OR xcart_categories.membership='')
and (xcart_pricing.membership=''
or xcart_pricing.membership='')
and (xcart_products.categoryid='105'
or xcart_products.categoryid1='105'
or xcart_products.categoryid2='105'
or xcart_products.categoryid3='105'
or xcart_products.categoryid4='105')
and xcart_products.forsale='Y'
group by xcart_products.productid limit 12
Reply With Quote