I have three tables in mysql which make up the dropdown menu, as below code. I would like to get a $ breadcrumb variable with link from this menu. Example:
Home / Woman
Home / Woman / Clothes
Home / Woman / Clothes / Women T-Shirth-2
It is possible??
<div id="sitemaps" class="menu">
<ul>
<li><a href="index.php">Home</a></li>
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_top_category WHERE show_on_menu=1");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
?>
<li><a href="product-category.php?id=<?php echo $row['tcat_id']; ?>&type=top-category"><?php echo $row['tcat_name']; ?></a>
<ul>
<?php
$statement1 = $pdo->prepare("SELECT * FROM tbl_mid_category WHERE tcat_id=?");
$statement1->execute(array($row['tcat_id']));
$result1 = $statement1->fetchAll(PDO::FETCH_ASSOC);
foreach ($result1 as $row1) {
?>
<li><a href="product-category.php?id=<?php echo $row1['mcat_id']; ?>&type=mid-category"><?php echo $row1['mcat_name']; ?></a>
<ul>
<?php
$statement2 = $pdo->prepare("SELECT * FROM tbl_end_category WHERE mcat_id=?");
$statement2->execute(array($row1['mcat_id']));
$result2 = $statement2->fetchAll(PDO::FETCH_ASSOC);
foreach ($result2 as $row2) {
?>
<li><a href="product-category.php?id=<?php echo $row2['ecat_id']; ?>&type=end-category"><?php echo $row2['ecat_name']; ?></a></li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
<div class="breadcrumb" style="margin-top:20px"><a href="<?php echo BASE_URL; ?>">Home / </a> <?php echo $breadcrumb ?>
</div>
tbl_top_category
+-------------+----------------------+--------+
| tcat_id | tcat_name | active |
+-------------+----------------------+--------+
| 1 | Men | 1 |
| 2 | Woman | 1 |
| 3 | Kids | 1 |
+-------------+----------------------+--------+
tbl_mid_category
+-------------+----------------------+--------+
| mcat_id | mcat_name | tcat_id|
+-------------+----------------------+--------+
| 1 | Men Shoes | 1 |
| 2 | Men Clothes | 1 |
| 3 | Men T-Shirth | 1 |
| 4 | Women Shoes | 2 |
| 5 | Women Clothes | 2 |
| 6 | Women T-Shirth | 2 |
| 7 | Kids Shoes | 3 |
| 8 | Kids Clothes | 3 |
| 9 | Kids T-Shirth | 3 |
+-------------+----------------------+--------+
tbl_end_category
+-------------+----------------------+--------+
| ecat_id | ecat_name | mcat_id|
+-------------+----------------------+--------+
| 1 | Men Shoes-1 | 1 |
| 2 | Men Shoes-2 | 1 |
| 3 | Men Shoes-3 | 1 |
| 4 | Men Clothes-1 | 2 |
| 5 | Men Clothes-2 | 2 |
| 6 | Men T-Shirth-1 | 3 |
| 7 | Men T-Shirth-2 | 3 |
| 8 | Women Shoes-1 | 4 |
| 9 | Women Shoes-2 | 4 |
| 10| Women Shoes-3 | 4 |
| 11| Women Clothes-1 | 5 |
| 12| Women Clothes-2 | 5 |
| 13| Women T-Shirth-1 | 6 |
| 14| Women T-Shirth-2 | 6 |
| 15| Kids Shoes-1 | 7 |
| 16| Kids Shoes-2 | 7 |
| 17| Kids Shoes-3 | 7 |
| 18| Kids Clothes-1 | 8 |
| 19| Kids Clothes-2 | 8 |
| 20| Kids T-Shirth-1 | 9 |
| 21| Kids T-Shirth-2 | 9 |
+-------------+----------------------+--------+