It seems to me you guys (Daniel & James, who have both helped me immensely with php over the years [thank you!]) are making this WAY more complicated than it needs to be. So, hopefully, I can finally help you with something. I may not be understanding exactly what you are trying to do, but this is how I would do it...
I simplified your table name to make it easier to follow. This is your code...
First, I agree with Traq that you need another column... but in the article table, not the artcat table.... a simple 1/0 field that indicates whether the article should be visible or not.Code:SELECT article.title, article.ID FROM article, artcat WHERE artcat.cat_ID=13 AND artcat.art_ID=article.ID AND artcat.cat_ID!=30 AND artcat.cat_ID!=29 ORDER BY title
or, without the `active` column...Code:SELECT * FROM articles WHERE art_id IN(SELECT art_id FROM artcat WHERE cat_id = 13) AND `active` = 1 ORDER BY `title`;
There you have your data with no php filters required. No muss, no fuss.Code:SELECT * FROM articles WHERE art_id IN(SELECT art_id FROM artcat WHERE cat_id = 13) AND `art_id` NOT IN(29,30, 47,etc) ORDER BY `title`;![]()



Reply With Quote
Bookmarks