I’m novice in backends but I really want to do this in some automatic way, the product pages I have to make are so many
hard to handle when I have to edit codes in the future
navigation menu
<ul class="category">
<li>
<a href="productsListPage.php">All Products</a>
<ul class="subCategory">
<li><a href="productsListPage.php" id="catA">Category A</a></li>
<li><a href="productsListPage.php" id="catB">Category B</a></li>
<li><a href="productsListPage.php" id="catC">Category C</a></li>
</ul>
</li>
</ul>
productsListPage.php
<div class="AAA" id="pr1">
<a href="productView.php"></a>
</div>
<div class="AAA" id="pr2">
<a href="productView.php"></a>
</div>
<div class="BBB" id="pr3">
<a href="productView.php"></a>
</div>
<div class="BBB" id="pr4">
<a href="productView.php"></a>
</div>
<div class="CCC" id="pr5">
<a href="productView.php"></a>
</div>
<div class="CCC" id="pr6">
<a href="productView.php"></a>
</div>
I want to make the links dynamically
and generate pages for each products automatically
like this I think?
<!--navigation menu-->
<ul class="category">
<li>
<a href="productsListPage.php">All Products</a>
<!--shows all products-->
<ul class="subCategory">
<li><a href="productsListPage.php?id=catA" id="catA">Category A</a></li>
<!--only shows products in category A-->
<li><a href="productsListPage.php?id=catB" id="catB">Category B</a></li>
<!--only shows products in category B-->
<li><a href="productsListPage.php?id=catC" id="catC">Category C</a></li>
<!--only shows products in category C-->
</ul>
</li>
</ul>
<!--productsListPage.php-->
<div class="AAA" id="pr1">
<a href="productView.php?id=pr1"></a>
</div>
<div class="AAA" id="pr2">
<a href="productView.php?id=pr2"></a>
</div>
<!--products in category A-->
<div class="BBB" id="pr3">
<a href="productView.php?id=pr3"></a>
</div>
<div class="BBB" id="pr4">
<a href="productView.php?id=pr4"></a>
</div>
<!--products in category B-->
<div class="CCC" id="pr5">
<a href="productView.php?id=pr5"></a>
</div>
<div class="CCC" id="pr6">
<a href="productView.php?id=pr6"></a>
</div>
<!--products in category C-->
and I wonder how can I link(put) certain products into certain categories
I got Bitnami WAMP installed
and I’ve set my PhpMyAdmin like this
database: products
ㄴ table: cat
ㄴ columns: categA, categB, categC
2
Answers
You should start by changing the database structure, fixing column name by categories is the start of your problem
You may start with creating two column (type = [A, B, C], name)
Then you can retrieve categories by SQL and display your list (something like this):
Try this
Table for category:- id int(10),name varchar(30)