I have two tables names book_list
and book_category
. Schema is like below:
book_list
+---------+--------+-----------+
| id_book | id_cat | book_name |
+---------+--------+-----------+
| 1 | 3 | Book Nam1 |
| 2 | 1 | Book Nam2 |
| 3 | 2 | Book Nam3 |
+---------+--------+-----------+
book_category
+--------+----------+-----------+-------+
| id_cat | cat_name | id_parent | level |
+--------+----------+-----------+-------+
| 1 | name1 | 0 | 1 |
| 2 | name1.1 | 1 | 2 |
| 3 |name1.1.1 | 2 | 3 |
+--------+----------+-----------+-------+
code tried:
SELECT a.id_book, a.id_cat, a.book_name, b.cat_name, b.level
FROM book_list a
INNER JOIN book_category b ON a.id_cat = b.id_cat
I need to manipulate the result array to add breadcrumb where each has link to itselfs like:
table row:
<td>3(id_book)</td>
<td>Book Nam3 (book_name)</td>
<td>
<a href="handle.php?id=<?=id_cat;?>">Name 1</a> »
<a href="handle.php?id=<?=id_cat;?>">Name 1.1</a> »
<a href="handle.php?id=<?=id_cat;?>">Name 1.1.1</a>
</td>
Hope I made my point and thank you for any help.