PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Dec 15, 2018 12:31 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Oct 22, 2014 6:10 am 
Offline
DevNet Master

Joined: Wed Oct 08, 2008 3:39 pm
Posts: 4426
Location: United Kingdom
Syntax: [ Download ] [ Hide ]
$query = ("SELECT * FROM products WHERE catid = :c AND (producttype_lightweight = 'yes' OR producttype_backlit = 'yes' OR producttype_traditional = 'yes') LIMIT $offset, $rowsPerPage");
 


I need to be able to assign each product to one that one top level product type, of three.

These are never changed, so I am choosing it to be static fields rather than dynamically named.
But when it comes to the category page, if they choose Lightweight as the top level, and then Marble as the second level, I want it to only show those where the category ID is for marble (easy) and producttype_lightweight is 'yes'.

But on the same set of code, if they chose Marble and producttype_traditional is 'yes', I want only products to show for that.

With the code above, it's showing me products that are in marble, but also in both lightweight and traditional. It's clear to see why, but I don't see another way around it.

There will be times when a product is in BOTH those top levels, or even three levels. But if they go to Traditional > Marble, I want it to only show those there the catid is for marble, and the traditional is a yes.

_________________
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.


Top
 Profile  
 
PostPosted: Wed Oct 22, 2014 2:11 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
simonmlewis wrote:
With the code above, it's showing me products that are in marble, but also in both lightweight and traditional. It's clear to see why, but I don't see another way around it.

I'm not sure how you're coming up with that query. They can only choose one top-level category, right? So you should never be doing a =yes for more than one at a time.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group