Ok, I'm a PHP newbie and I have a snippet of code that works to limit results to a set category, I need to change that so it limits the results to a range of categories:
Right now it only returns items in Cat number 2, I need it to return items from 2,3,4,5,6,7 - nothing I'm trying is working...
$currentItem = K2Table::getInstance('K2Item', 'Table');
$currentItem->load($itemID);
$itemCat = $currentItem->get('catid');
$includeCat = 2;
if($includeCat)
$query .= " AND c.id = {$includeCat} ";
thanks!
Limit results by range
Moderator: General Moderators
Re: Limit results by range
Code: Select all
$includeCat = array(2, 3, 4, 5, 6, 7);
if ($includeCat) {
$query .= " AND c.id IN (" . implode(',', $includeCat) . ")";
}Re: Limit results by range [Solved]
Thank you!!!! I was missing the implode part 
Re: Limit results by range
Thank you Celauran, I needed that too.