View Single Post
Old 06-06-2008, 05:24 PM   #3 (permalink)
buggabill
The Contributor
 
buggabill's Avatar
 
Join Date: Jan 2008
Location: Maine, USA
Posts: 92
Thanks: 2
buggabill is on a distinguished road
Default

One thing that you could do is take your array and implode it into a string.

php Code:
$strcat = implode(', ', $arrcat);

// For example say you have a sample array
// that looks like this:
//   $arrcat = array(1, 3, 5);
// The first step will take the array
// and implode it into $strcat like so:
// $strcat = '1, 3, 5';
 

Then use that string in the query for the criteria (Note the use of the IN keyword:
php Code:
$sql = 'SELECT PO.strTitle, PO.bFeatured, PO.strPreview, PO.strFile, PO.dateCreated AS tsCreated, DATE_FORMAT(PO.dateCreated, '%b, %D %Y %l:%i %p') AS dateCreated, PO.nPostId, PO.nPostType, PO.strPost, PO.strAbout, PO.nViews, CA.strCategory, CA.nCategoryId, CA.nParentCategoryId FROM tblposts PO INNER JOIN tblcategories CA ON CA.nCategoryId = PO.nCategoryId WHERE CA.nCategoryId IN ('.$strcat.') AND PO.bFeatured = 1';
__________________
-- Bill
"Why is it drug addicts and computer aficionados are both called users?" -Clifford Stoll

Last edited by buggabill : 06-06-2008 at 05:25 PM. Reason: One little 'n'...
buggabill is offline  
Reply With Quote