I have around 5 meal category, for example 'M01' ('M' stands for Meal), 'B01' ('B' stands for Baverages) and so on. In every category page on front end, instead of showing everything in 1 page, I want to sort the product based on its category, for example in Baverages page, there will be a list of baverages under 'B01' category code. How can I achieve that with PHP and MySQLi? Sorry for the simple code, I'm still new to this. Thanks in advance!
Here's my code:
<table class="table-list">
<tbody id="mealTable">
<?php
$result=mysqli_query($conn,"SELECT * FROM meal");
$row_count = mysqli_num_rows($result);
if ($row_count == 0) { ?>
<tr>
<td colspan = "6">
<?php echo "No data found"; ?>
</td>
</tr>
<?php } else {
while($row = mysqli_fetch_array($result)) { ?>
<tr>
<td><?php echo $row['meal_name']?></td>
<td>RM <?php echo $row['meal_price']?></td>
<td ><a href="addtocart.php?mid=<?php echo $row['meal_id']; ?>" style="background-color: green; color: white; padding: 10px 10px; text-align: center; text-decoration: none; display: inline-block;font-size: 14px; width: 70px; height: 13px; ">Add To Cart</a>
</td>
</tr>
<?php } }
?>
</div>
This is the List of Meal page on Admin side