Yesterday when I was working on php script I noticed that categories and subcategories works seperatly if I clicked on main category its show all articles under this main category and nothing imported from subcategories, now am working on somthing like this, so what should I do to avoid this mistake ? someone told me to use inner join but really I don't get the whole picture of this. I can't imagin how I can use this in my SQL command. for example Category with id = 1 has subcategories with parent_id = 1 thier ids are : 15 - 20 - 38 if I specified category 1 in my search it will show all items alson in subcategories .
as you mentioned above you creat item category table in that table store category id from your Category table and then use this query to fetch data $subcategory="select * from item category where category_id='$cat'"; and also you have to insert category id in your item category table when you insert data in item category i hope you will get me
am sorry for late in response , I'll try blocblue code and return with answer.
EDIT: forgive my stupidity in this but here is what I want when user click on mypage.php?cat=5 which is main category it will show all items under subcategory that has active value = 1 I tried to edit this sql and nothing appeared.
$sql ="SELECT `i`.*
FROM `ads` `i`
INNER JOIN `category` `c` ON (`c`.`cat_id` = `i`.`ad_cat`)
WHERE (`c`.`cat_id` = ".$cat_id." OR `c`.`parent_id` = 1) AND ad_active = 1 ORDER BY ad_date DESC";