On this previous tutorial we have discussed regarding how to create multi-level category using recursive function in PHP,Mysql. Now have to show products according to multi-level category selected in PHP,Mysql.
Above we created a new function i.e sub_cids .Here we have $cid variable on this page in get mode means reading it from url that passed from 'left.php' after category click . So here on this function we finds all sub level category's id so that we can show product according it's level . For demonstration consider We have category like
Step 1
First of all let's do the below code in left.php to acheive multi-level category on left side as shown on above image .
p_cid to handle parent cide and space to maintain spaces of category depth level as shown above in image .We listed all main category with there sub level category . Looking to sharp your PHP knowledge ,Visit us www.unitedwebsoft.in for complete advance PHP course .We cover a complete e-commerce project based training that build your confidence to do any web project .We also started Laravel PHP MVC framework training
Step 2
On our products.php page to show list of products according to category click .We have to code below .
Above we created a new function i.e sub_cids .Here we have $cid variable on this page in get mode means reading it from url that passed from 'left.php' after category click . So here on this function we finds all sub level category's id so that we can show product according it's level . For demonstration consider We have category like
So, for this condition if we have 2 product one under 'Galaxy Tab' and other under 'Windows' category .
Now if someone click on mobile, it will show 2 products .
If someone clicks any among android ,samsung or galaxy tab ,it will show only 1 product.
Similarly if someone click on 'windows' category ,it will show other 1 product .
To use this tutorial in your project you should have at least 2 tables 'category' and 'products'. Download this database tables If you have any query ,you can ask me through below comment . For advance level PHP training visit www.unitedwebsoft.in