L
L
luckyjenro02021-06-09 23:23:24
PHP
luckyjenro0, 2021-06-09 23:23:24

How to track categories?

There is a website, a regular online store, I started to create an admin panel, I think - how to do something that the admin could add categories, and products were displayed from them:

Here is the code for displaying products from the database on the page:

<div class="items">
                        <?
                      $goods_perm = mysqli_query($link, "SELECT * FROM `donate` WHERE type='surv-case' ORDER BY `price`");
                      while ($row = mysqli_fetch_assoc($goods_perm)) {
                        $perm_id = $row['id'];
                        $perm_name = $row['name'];
                        $perm_img = $row['img-url'];
                        $perm_price = $row['price'];
                        $perm_price_old = $row['price-old'];
                        $perm_sale = $row['sale'];
                                                                                                $group_perm = $row['group-perm'];
                      ?>
                        <div class="item-id js-open-modal" data-modal="paymodal" id="openModal" data-prices="<?=$perm_price?>" data-product="<?=$perm_name?>" data-server="<?=$server?>" data-group="<?=$group_perm?>">
                            <div class="title"><?=$perm_name?></div>
                            <div class="sale">-<?=$perm_sale?>%</div>
                            <div class="image" style="background-image: url('<?=$perm_img?>');"></div>
                            <div class="price"><?=$perm_price?>.00 <i class="fa fa-ruble"></i></div>
                        </div>
                        <?}?>
                    </div>


The code says that the output is produced for products that have a certain 'type', if the user adds his categories and specifies it in the product, how to write the output of products on the page correctly?
I will not think the correct request to a DB.

Once again, who did not understand: there is a code for displaying goods of a specific category from the database (type=...). The output categories are written in the code right now, but if I want to enable a person to create categories himself, how to make it all universal so that a person does not change the output code each time, rearranging the sql query to the desired category, and all this was automatically done, the person added the category to site -> added a product in which he indicated the category of the product -> the product was displayed, what code should I use?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question